feat: establish composed color field and input group protocols
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createSSRApp, defineComponent } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import ColorField from "../packages/vue/src/components/color-field/ColorField.vue";
|
||||
import ColorInputGroup from "../packages/vue/src/components/color-field/ColorInputGroup.vue";
|
||||
import ColorInputGroupInput from "../packages/vue/src/components/color-field/ColorInputGroupInput.vue";
|
||||
import { Label, Description, FieldError } from "../packages/vue/src/index";
|
||||
const components = {
|
||||
ColorField,
|
||||
ColorInputGroup,
|
||||
ColorInputGroupInput,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
};
|
||||
async function html(template: string) {
|
||||
return renderToString(
|
||||
createSSRApp(defineComponent({ components, template })),
|
||||
);
|
||||
}
|
||||
describe("composed color field actual Node SSR", () => {
|
||||
it("plans an explicit leaf id before the preceding native label and field descriptions", async () => {
|
||||
const result = await html(
|
||||
'<ColorField name="color" default-value="#123456"><Label>Color</Label><ColorInputGroup><ColorInputGroupInput id="native"/></ColorInputGroup><Description>Hint</Description></ColorField>',
|
||||
);
|
||||
expect(result).toContain('for="native"');
|
||||
expect(result).toContain('id="native"');
|
||||
expect(result).toContain("aria-describedby=");
|
||||
expect(result.match(/name="color"/g)).toHaveLength(1);
|
||||
expect(result).toContain('value="#123456"');
|
||||
});
|
||||
it("uses percent display and numeric form scale with one name, without browser globals", async () => {
|
||||
const result = await html(
|
||||
'<ColorField name="saturation" channel="saturation" color-space="hsb" default-value="hsb(270,50%,50%)"><ColorInputGroup><ColorInputGroupInput/></ColorInputGroup></ColorField>',
|
||||
);
|
||||
expect(result).toContain('value="50%"');
|
||||
expect(result).toContain('value="0.5"');
|
||||
expect(result.match(/name="saturation"/g)).toHaveLength(1);
|
||||
expect(result).toContain('aria-label="saturation"');
|
||||
});
|
||||
it("keeps standalone group native attributes and excludes disabled channel submission", async () => {
|
||||
const result = await html(
|
||||
'<main><ColorInputGroup><ColorInputGroupInput name="text" default-value="plain" autocomplete="username"/></ColorInputGroup><ColorField name="alpha" channel="alpha" is-disabled default-value="#123456"><ColorInputGroup><ColorInputGroupInput/></ColorInputGroup></ColorField></main>',
|
||||
);
|
||||
expect(result).toContain('value="plain"');
|
||||
expect(result).toContain('autocomplete="username"');
|
||||
expect(result).toContain('name="alpha" disabled');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user