| ... | @@ -1,76 +0,0 @@ |
| 1 | import { renderToStaticMarkup } from "react-dom/server"; |
| 2 | import { BotIcon } from "lucide-react"; |
| 3 | import { describe, expect, it } from "vite-plus/test"; |
| 4 | |
| 5 | import { |
| 6 | ComposerControl, |
| 7 | ComposerControlChevron, |
| 8 | ComposerControlIcon, |
| 9 | ComposerControlSeparator, |
| 10 | } from "./ComposerControl"; |
| 11 | |
| 12 | describe("ComposerControl", () => { |
| 13 | it("preserves the expanded composer geometry by default", () => { |
| 14 | const markup = renderToStaticMarkup(<ComposerControl>Model</ComposerControl>); |
| 15 | |
| 16 | expect(markup).toContain("h-7"); |
| 17 | expect(markup).toContain("min-h-7"); |
| 18 | expect(markup).toContain("gap-1.5"); |
| 19 | expect(markup).toContain("px-2.5"); |
| 20 | }); |
| 21 | |
| 22 | it("uses the shared xs geometry for resting controls", () => { |
| 23 | const markup = renderToStaticMarkup( |
| 24 | <ComposerControl size="xs"> |
| 25 | Model |
| 26 | <ComposerControlChevron size="xs" /> |
| 27 | </ComposerControl>, |
| 28 | ); |
| 29 | |
| 30 | expect(markup).toContain("sm:h-6"); |
| 31 | expect(markup).toContain("font-normal"); |
| 32 | expect(markup).toContain("text-muted-foreground/70"); |
| 33 | expect(markup).toContain("[--control-icon-color:currentColor]"); |
| 34 | expect(markup).toContain("svg[data-composer-control-chevron]]:ms-0"); |
| 35 | expect(markup).toContain("svg[data-composer-control-chevron]]:-me-1"); |
| 36 | expect(markup).not.toContain("min-h-7"); |
| 37 | expect(markup).not.toContain("gap-1.5"); |
| 38 | expect(markup).not.toContain("px-2.5"); |
| 39 | }); |
| 40 | |
| 41 | it("keeps the expanded chevron treatment unless resting overrides it", () => { |
| 42 | const expanded = renderToStaticMarkup(<ComposerControlChevron />); |
| 43 | const resting = renderToStaticMarkup(<ComposerControlChevron size="xs" />); |
| 44 | |
| 45 | expect(expanded).toContain("size-3.5"); |
| 46 | expect(expanded).toContain("text-icon-muted"); |
| 47 | expect(expanded).toContain('stroke-width="2.25"'); |
| 48 | expect(resting).toContain("size-3"); |
| 49 | expect(resting).toContain("text-current"); |
| 50 | expect(resting).toContain("opacity-50"); |
| 51 | expect(resting).not.toContain("size-3.5"); |
| 52 | expect(resting).not.toContain("text-icon-muted"); |
| 53 | }); |
| 54 | |
| 55 | it("owns resting icon geometry", () => { |
| 56 | const expanded = renderToStaticMarkup(<ComposerControlIcon icon={BotIcon} />); |
| 57 | const resting = renderToStaticMarkup(<ComposerControlIcon icon={BotIcon} size="xs" />); |
| 58 | |
| 59 | expect(expanded).toContain("size-4"); |
| 60 | expect(resting).toContain("size-3"); |
| 61 | expect(resting).not.toContain("size-4"); |
| 62 | }); |
| 63 | |
| 64 | it("owns separator geometry for both composer sizes", () => { |
| 65 | const expanded = renderToStaticMarkup(<ComposerControlSeparator />); |
| 66 | const resting = renderToStaticMarkup( |
| 67 | <ComposerControlSeparator size="xs" data-resting-controls-separator="true" />, |
| 68 | ); |
| 69 | |
| 70 | expect(expanded).toContain("h-4"); |
| 71 | expect(expanded).not.toContain("h-3.5!"); |
| 72 | expect(resting).toContain("h-3.5!"); |
| 73 | expect(resting).not.toContain("h-4"); |
| 74 | expect(resting).toContain('data-resting-controls-separator="true"'); |
| 75 | }); |
| 76 | }); |