diff --git a/src/components/__tests__/emoji-picker.test.browser.tsx b/src/components/__tests__/emoji-picker.test.browser.tsx index 378559b..107e099 100644 --- a/src/components/__tests__/emoji-picker.test.browser.tsx +++ b/src/components/__tests__/emoji-picker.test.browser.tsx @@ -438,23 +438,22 @@ describe("EmojiPicker.Root", () => { it("should support disabling sticky category headers", async () => { page.render( ( -
+
{category.label}
), }} + sticky={false} />, ); - await expect.element(page.getByTestId("category-header").nth(1)).not.toHaveStyle({ - position: "sticky", - }); + await expect + .element(page.getByTestId("category-header").nth(1)) + .not.toHaveStyle({ + position: "sticky", + }); }); }); @@ -531,82 +530,100 @@ describe("EmojiPicker.Search", () => { }); describe("EmojiPicker.Viewport", () => { - it("should virtualize rows based on the viewport height", async () => { - function Page() { - const [viewportHeight, setViewportHeight] = useState(400); - const [rowHeight, setRowHeight] = useState(30); - const [categoryHeaderHeight, setCategoryHeaderHeight] = useState(30); - - return ( - ( -
- {children} -
- ), - CategoryHeader: ({ category, style, ...props }) => ( -
- {category.label} -
- ), - }} - > - setViewportHeight(Number(event.target.value))} - type="number" - value={viewportHeight} - /> - setRowHeight(Number(event.target.value))} - type="number" - value={rowHeight} - /> - - setCategoryHeaderHeight(Number(event.target.value)) - } - type="number" - value={categoryHeaderHeight} - /> -
- ); - } + it.each([ + ["with sticky headers", true], + ["without sticky headers", false], + ])( + "should virtualize rows based on the viewport height %s", + async (_, sticky) => { + function Page() { + const [viewportHeight, setViewportHeight] = useState(400); + const [rowHeight, setRowHeight] = useState(30); + const [categoryHeaderHeight, setCategoryHeaderHeight] = useState(30); + + return ( + ( +
+ {children} +
+ ), + CategoryHeader: ({ category, style, ...props }) => ( +
+ {category.label} +
+ ), + }} + sticky={sticky} + > + + setViewportHeight(Number(event.target.value)) + } + type="number" + value={viewportHeight} + /> + setRowHeight(Number(event.target.value))} + type="number" + value={rowHeight} + /> + + setCategoryHeaderHeight(Number(event.target.value)) + } + type="number" + value={categoryHeaderHeight} + /> +
+ ); + } - page.render(); + page.render(); - await expect.element(page.getByText("😀")).toBeInTheDocument(); + await expect.element(page.getByText("😀")).toBeInTheDocument(); - await expect.element(page.getByRole("row").nth(10)).toBeInTheDocument(); - await expect.element(page.getByRole("row").nth(20)).not.toBeInTheDocument(); + await expect.element(page.getByRole("row").nth(10)).toBeInTheDocument(); + await expect + .element(page.getByRole("row").nth(20)) + .not.toBeInTheDocument(); - await page.getByTestId("viewport-height").fill("500"); - await page.getByTestId("row-height").fill("20"); - await page.getByTestId("category-header-height").fill("20"); + await page.getByTestId("viewport-height").fill("500"); + await page.getByTestId("row-height").fill("20"); + await page.getByTestId("category-header-height").fill("20"); - await expect.element(page.getByRole("row").nth(10)).toBeInTheDocument(); - await expect.element(page.getByRole("row").nth(20)).toBeInTheDocument(); + await expect.element(page.getByRole("row").nth(10)).toBeInTheDocument(); + await expect.element(page.getByRole("row").nth(20)).toBeInTheDocument(); - await page.getByTestId("viewport-height").fill("200"); - await page.getByTestId("row-height").fill("100"); - await page.getByTestId("category-header-height").fill("400"); + await page.getByTestId("viewport-height").fill("200"); + await page.getByTestId("row-height").fill("100"); + await page.getByTestId("category-header-height").fill("400"); - await expect.element(page.getByRole("row").nth(10)).not.toBeInTheDocument(); - await expect.element(page.getByRole("row").nth(20)).not.toBeInTheDocument(); - }); + await expect + .element(page.getByRole("row").nth(10)) + .not.toBeInTheDocument(); + await expect + .element(page.getByRole("row").nth(20)) + .not.toBeInTheDocument(); + }, + ); - it("should virtualize rows based on scroll", async () => { + it.each([ + ["with sticky headers", true], + ["without sticky headers", false], + ])("should virtualize rows based on scroll %s", async (_, sticky) => { function Page() { const scrollViewport = () => { const viewport = document.querySelector("[data-testid='viewport']"); @@ -618,7 +635,7 @@ describe("EmojiPicker.Viewport", () => { }; return ( - +