// @vitest-environment node import { describe, it, expect } from "vitest"; import { createSSRApp, defineComponent, h } from "vue"; import { renderToString } from "@vue/server-renderer"; import Picker from "../packages/vue/tests/fixtures/ColorPickerFoundation.vue"; import Area from "../packages/vue/tests/fixtures/ColorAreaFoundation.vue"; import { parseColor } from "../packages/vue/src/components/color/value"; describe("private color foundation actual Node SSR", () => { it("renders accepted polar values, two native axes and one submission without browser globals", async () => { const html = await renderToString( createSSRApp( defineComponent({ render: () => h(Picker, { defaultValue: parseColor("hsb(270,0%,50%,.5)"), name: "color", }), }), ), ); expect(html).toContain("hsba(270, 0%, 50%, 0.5)"); expect(html).toContain('aria-label="saturation"'); expect(html).toContain('aria-label="brightness"'); expect(html.match(/name="color"/g)).toHaveLength(1); expect(html).not.toContain('role="application"'); }); it("renders a swapped hue axis and RGB area deterministically", async () => { const html = await renderToString( createSSRApp( defineComponent({ render: () => h("main", [ h(Area, { defaultValue: "hsb(240,50%,50%)", xChannel: "brightness", yChannel: "hue", colorSpace: "hsb", }), h(Area, { defaultValue: "#123456", colorSpace: "rgb", dir: "rtl", }), ]), }), ), ); expect(html).toContain("background-blend-mode:screen"); expect(html).toContain("linear-gradient(to top, rgb"); expect(html).not.toContain("NaN"); }); });