add: unit and integration testing
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
const { filterJson } = require("../src/search");
|
||||
|
||||
describe("filterJson", () => {
|
||||
// deliberately adding an extra property that is not supposed to be there
|
||||
test("keeps only url, title, and content", () => {
|
||||
const input = [
|
||||
{
|
||||
url: "https://example.com",
|
||||
title: "Example",
|
||||
content: "Some content",
|
||||
engine: "startpage",
|
||||
score: 0.9
|
||||
}
|
||||
];
|
||||
|
||||
expect(filterJson(input)).toEqual([
|
||||
{
|
||||
url: "https://example.com",
|
||||
title: "Example",
|
||||
content: "Some content"
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
test("returns an empty array for empty input", () => {
|
||||
expect(filterJson([])).toEqual([]);
|
||||
});
|
||||
|
||||
test("handles multiple results", () => {
|
||||
const input = [
|
||||
{ url: "one", title: "One", content: "First" },
|
||||
{ url: "two", title: "Two", content: "Second" }
|
||||
];
|
||||
|
||||
expect(filterJson(input)).toEqual(input);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user