import { afterEach, describe, expect, it } from "vitest"; import { mount } from "@vue/test-utils"; import { readFileSync } from "node:fs"; import { ColorSwatch } from "../packages/vue/src"; import Basic from "../apps/docs/demos/color-swatch-basic.vue"; import Sizes from "../apps/docs/demos/color-swatch-sizes.vue"; import Shapes from "../apps/docs/demos/color-swatch-shapes.vue"; import Transparency from "../apps/docs/demos/color-swatch-transparency.vue"; import RenderFunction from "../apps/docs/demos/color-swatch-render-function.vue"; import Accessibility from "../apps/docs/demos/color-swatch-accessibility.vue"; import CustomStyles from "../apps/docs/demos/color-swatch-custom-styles.vue"; const mounted: ReturnType[] = []; function render(component: Parameters[0]) { const w = mount(component, { attachTo: document.body }); mounted.push(w); return w; } afterEach(() => { mounted.splice(0).forEach((w) => w.unmount()); document.body.innerHTML = ""; }); const previews = [ "basic", "sizes", "shapes", "transparency", "render-function", "accessibility", "custom-styles", ]; describe("ColorSwatch documentation demos", () => { it("keeps the seven pinned previews in the upstream order", () => { const document = readFileSync( "apps/docs/components/color-swatch.md", "utf8", ); const names = [ ...document.matchAll(/ match[1]); expect(names).toEqual(previews); for (const name of previews) { const source = readFileSync( `apps/docs/demos/color-swatch-${name}.vue`, "utf8", ); expect(source).toContain("