mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
Added test for flat array input data
This commit is contained in:
parent
655a205b0a
commit
56ebbb4cbf
3 changed files with 88 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
import { render, screen } from "@testing-library/svelte";
|
||||
import { user } from "../setup-tests";
|
||||
import TreeView from "./TreeView.test.svelte";
|
||||
import TreeViewFlatArray from "./TreeViewFlatArray.test.svelte";
|
||||
|
||||
describe("TreeView", () => {
|
||||
const getItemByName = (name: RegExp) => {
|
||||
|
@ -37,4 +38,14 @@ describe("TreeView", () => {
|
|||
text: "AI / Machine learning",
|
||||
});
|
||||
});
|
||||
|
||||
it("can turn flat array into nested array", async () => {
|
||||
const consoleLog = vi.spyOn(console, "log");
|
||||
render(TreeViewFlatArray);
|
||||
const firstItem = getItemByName(/Blockchain/);
|
||||
expect(firstItem).toBeInTheDocument();
|
||||
await user.click(firstItem);
|
||||
expect(getSelectedItemByName(/Blockchain/)).toBeInTheDocument();
|
||||
expect(consoleLog).toBeCalledWith("selectedIds", [7]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue