Open History to see the last commit
1import { renderToStaticMarkup } from "react-dom/server";
2import { describe, expect, it } from "vite-plus/test";
3
4import { Command, CommandFooter, CommandInput } from "./command";
5
6describe("command compact geometry", () => {
7 it("keeps shell selectors on the wrapper and direct-input padding on AutocompleteInput", () => {
8 const html = renderToStaticMarkup(
9 <Command>
10 <CommandInput placeholder="Search commands" />
11 </Command>,
12 );
13 const shellClass = html.match(/class="([^"]*px-\[var\(--command-shell-inset\)[^"]*)"/)?.[1];
14 const inputClass = html.match(/class="([^"]*has-focus-visible:ring-0[^"]*)"/)?.[1];
15
16 expect(shellClass).toContain(
17 "[&_[data-slot=autocomplete-start-addon]]:ps-[calc(var(--command-shell-inset)+0.0625rem)]",
18 );
19 expect(shellClass).not.toContain("sm:*:data-[slot=autocomplete-input]");
20 expect(inputClass).toContain(
21 "sm:*:data-[slot=autocomplete-input]:ps-[calc(var(--command-shell-inset)+1.5rem)]!",
22 );
23 });
24
25 it("uses the semantic footer inset without changing compact vertical padding", () => {
26 const html = renderToStaticMarkup(<CommandFooter>Shortcuts</CommandFooter>);
27
28 expect(html).toContain("px-[var(--command-content-inset)]");
29 expect(html).toContain("py-2.5");
30 });
31});