|
1 | | -import { render, screen } from "@testing-library/svelte"; |
| 1 | +import { render, screen, within } from "@testing-library/svelte"; |
2 | 2 | import { user } from "../../setup-tests"; |
3 | 3 | import Snippets from "./Snippets.test.svelte"; |
4 | 4 |
|
5 | 5 | describe("Svelte 5 Snippets", () => { |
| 6 | + describe("DataTable expandIcon", () => { |
| 7 | + it("should render custom expand icon via expandIcon snippet with expanded, row, and props", async () => { |
| 8 | + const { container } = render(Snippets); |
| 9 | + |
| 10 | + const datatable = screen.getByTestId( |
| 11 | + "datatable-expand-icon-snippet-container", |
| 12 | + ); |
| 13 | + expect(datatable).toBeInTheDocument(); |
| 14 | + |
| 15 | + const customIcons = screen.getAllByTestId( |
| 16 | + "datatable-expand-icon-snippet", |
| 17 | + ); |
| 18 | + expect(customIcons.length).toBeGreaterThanOrEqual(2); |
| 19 | + |
| 20 | + const firstExpandButton = screen.getAllByRole("button", { |
| 21 | + name: /expand/i, |
| 22 | + })[0]; |
| 23 | + const iconInButton = within(firstExpandButton).getByTestId( |
| 24 | + "datatable-expand-icon-snippet", |
| 25 | + ); |
| 26 | + expect(iconInButton).toHaveAttribute("data-expanded", "false"); |
| 27 | + |
| 28 | + await user.click(firstExpandButton); |
| 29 | + |
| 30 | + expect(iconInButton).toHaveAttribute("data-expanded", "true"); |
| 31 | + |
| 32 | + const expandedContent = container.querySelector( |
| 33 | + ".bx--child-row-inner-container", |
| 34 | + ); |
| 35 | + expect(expandedContent).toBeInTheDocument(); |
| 36 | + }); |
| 37 | + }); |
| 38 | + |
6 | 39 | describe("Dropdown", () => { |
7 | 40 | it("should render snippet with item and index arguments", async () => { |
8 | 41 | render(Snippets); |
|
0 commit comments