Skip to content

Commit

Permalink
Test dataFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
mbraak committed Apr 1, 2024
1 parent 7daa526 commit e300b00
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/jqTree/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,26 @@ describe("closedIcon", () => {
});
});

describe("dataFilter", () => {
it("changes the loaded data", async () => {
server.use(http.get("/tree/", () => HttpResponse.json(exampleData)));

const dataFilter = jest.fn((data) => [data[1]]);

Check failure on line 232 in src/test/jqTree/options.test.ts

View workflow job for this annotation

GitHub Actions / runner-job

Unsafe return of an `any[]` typed value

Check failure on line 232 in src/test/jqTree/options.test.ts

View workflow job for this annotation

GitHub Actions / runner-job

Unsafe member access [1] on an `any` value

const $tree = $("#tree1");
$tree.tree({
dataFilter,
dataUrl: "/tree/",
});

await screen.findByText("node2");

screen.queryByText;
expect(screen.queryByText("node1")).toBeNull();
expect(dataFilter).toHaveBeenCalledWith(exampleData);
});
});

describe("dataUrl", () => {
const exampleStructure = [
expect.objectContaining({ name: "node1" }),
Expand Down

0 comments on commit e300b00

Please sign in to comment.