40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
// @vitest-environment node
|
|
import { describe, it, expect } from "vitest";
|
|
import { createSSRApp, defineComponent } from "vue";
|
|
import { renderToString } from "@vue/server-renderer";
|
|
import Input from "../packages/vue/tests/fixtures/ColorInputFoundation.vue";
|
|
import Picker from "../packages/vue/tests/fixtures/ColorPickerFoundation.vue";
|
|
describe("private color inputs actual Node SSR", () => {
|
|
it("renders localized text and exact fractional native channel without browser globals", async () => {
|
|
const html = await renderToString(
|
|
createSSRApp(
|
|
defineComponent({
|
|
components: { Input, Picker },
|
|
template:
|
|
'<Picker default-value="hsb(270,0%,50%,.12345)" v-slot><Input channel="alpha" locale="de-DE" name="alpha"/><Input mode="range" channel="hue" name="hue"/></Picker>',
|
|
}),
|
|
),
|
|
);
|
|
expect(html).toContain('value="12,345"');
|
|
expect(html).toContain('value="0.12345"');
|
|
expect(html).toContain('value="270"');
|
|
expect(html).toContain('aria-valuetext="270°"');
|
|
expect(html.match(/name="alpha"/g)).toHaveLength(1);
|
|
expect(html).not.toContain("NaN");
|
|
});
|
|
it("renders empty fields and native validation association deterministically", async () => {
|
|
const html = await renderToString(
|
|
createSSRApp(
|
|
defineComponent({
|
|
components: { Input },
|
|
template:
|
|
'<Input name="color" form="external" is-required aria-label="Required color"/>',
|
|
}),
|
|
),
|
|
);
|
|
expect(html).toContain('aria-required="true"');
|
|
expect(html).toContain('form="external"');
|
|
expect(html).toContain('value=""');
|
|
});
|
|
});
|