import { renderToString } from "react-dom/server"; import { describe, expect, test } from "vitest"; import { SendouSelect, SendouSelectItem, SendouSelectItemSection, } from "./Select"; const SEASONS = [ { id: 2, name: "Season 2" }, { id: 1, name: "Season 1" }, ]; function SeasonItem({ season }: { season: (typeof SEASONS)[number] }) { return {season.name}; } describe("SendouSelect", () => { test("server renders the selected item's content in the trigger", () => { const html = renderToString( {(season) => ( {season.name} )} , ); expect(html).toContain("Season 1"); expect(html).not.toContain("data-placeholder"); expect(html).not.toContain("Pick a season"); }); test("server renders the selection rendered through a wrapper component keyed by its id", () => { const html = renderToString( {SEASONS.map((season) => ( ))} , ); expect(html).toContain("Season 1"); expect(html).not.toContain("Pick a season"); }); test("server renders the placeholder and no options without a selection", () => { const html = renderToString( {(season) => ( {season.name} )} , ); expect(html).toContain("Pick a season"); expect(html).not.toContain('role="option"'); expect(html).not.toContain('role="group"'); }); });