feat: migrate DateField and shared date input group
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// @vitest-environment node
|
||||
import { expect, it } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { parseZonedDateTime } from "@internationalized/date";
|
||||
import {
|
||||
DateField,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
Label,
|
||||
Description,
|
||||
} from "../packages/vue/src";
|
||||
it("renders public DateField and complete ISO values on Node with stable, unique field associations", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const date = parseZonedDateTime(
|
||||
"2024-03-10T01:30:45-08:00[America/Los_Angeles]",
|
||||
);
|
||||
const field = () =>
|
||||
h(
|
||||
DateField,
|
||||
{
|
||||
defaultValue: date,
|
||||
name: "date",
|
||||
granularity: "minute",
|
||||
locale: "en-US",
|
||||
},
|
||||
() => [
|
||||
h(Label, () => "Date"),
|
||||
h(DateFieldGroup, () => h(DateFieldInput)),
|
||||
h(Description, () => "Help"),
|
||||
],
|
||||
);
|
||||
const app = () =>
|
||||
createSSRApp({ render: () => h("form", [field(), field()]) });
|
||||
const html = await renderToString(app());
|
||||
expect(html).toBe(await renderToString(app()));
|
||||
expect(html.match(/name="date"/g)).toHaveLength(2);
|
||||
expect(
|
||||
html.match(/value="2024-03-10T01:30:45-08:00\[America\/Los_Angeles\]"/g),
|
||||
).toHaveLength(2);
|
||||
const ids = [...html.matchAll(/ id="([^"]+)"/g)].map((match) => match[1]);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
expect(html).toContain("aria-labelledby=");
|
||||
expect(html).toContain("aria-describedby=");
|
||||
});
|
||||
Reference in New Issue
Block a user