import { afterEach, describe, expect, it, vi } from "vitest"; import { mount } from "@vue/test-utils"; import { nextTick, type Component } from "vue"; import { readFileSync } from "node:fs"; const settle = () => new Promise((resolve) => setTimeout(resolve, 4)); const mounted: { unmount: () => void }[] = []; const previews = [ "default", "full-width", "with-description", "required", "disabled", "with-disabled-options", "with-sections", "controlled", "controlled-input-value", "asynchronous-loading", "default-selected-key", "allows-custom-value", "custom-indicator", "custom-value", "custom-filtering", "render-function", "menu-trigger", "form-value", "validation-behavior", "custom-validation", "read-only", "multiple-selection", "on-surface", "custom-styles", ]; afterEach(async () => { while (mounted.length) mounted.pop()?.unmount(); await nextTick(); await settle(); vi.restoreAllMocks(); document.body.innerHTML = ""; }); describe("ComboBox docs and demos", () => { it("keeps the pinned preview order and one demo per preview", () => { const document = readFileSync("apps/docs/components/combo-box.md", "utf8"); const names = [ ...document.matchAll(/ match[1]); expect(names).toEqual(previews); for (const name of previews) { const source = readFileSync( `apps/docs/demos/combo-box-${name}.vue`, "utf8", ); expect(source, name).toContain("