import { afterEach, describe, expect, it } from "vitest"; import { mount, flushPromises } from "@vue/test-utils"; import { readFileSync } from "node:fs"; import { ColorArea, Select, parseColor } from "../packages/vue/src"; import Basic from "../apps/docs/demos/color-area-basic.vue"; import WithDots from "../apps/docs/demos/color-area-with-dots.vue"; import SpaceAndChannels from "../apps/docs/demos/color-area-space-and-channels.vue"; import Disabled from "../apps/docs/demos/color-area-disabled.vue"; import Controlled from "../apps/docs/demos/color-area-controlled.vue"; import RenderFunction from "../apps/docs/demos/color-area-render-function.vue"; import CustomStyles from "../apps/docs/demos/color-area-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 root = (w: ReturnType) => w.get("[data-slot=color-area]"); const thumb = (w: ReturnType) => w.get("[data-slot=color-area-thumb]"); const axis = (w: ReturnType, name: "x" | "y") => w.get(`[data-axis="${name}"]`); const previews = [ "basic", "with-dots", "space-and-channels", "disabled", "controlled", "render-function", "custom-styles", ]; describe("ColorArea documentation demos", () => { it("keeps the seven pinned previews in the upstream order", () => { const document = readFileSync("apps/docs/components/color-area.md", "utf8"); const names = [ ...document.matchAll(/ match[1]); expect(names).toEqual(previews); for (const name of previews) { const source = readFileSync( `apps/docs/demos/color-area-${name}.vue`, "utf8", ); expect(source).toContain("