59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { createSSRApp, h } from "vue";
|
|
import { renderToString } from "@vue/server-renderer";
|
|
import { parseZonedDateTime } from "@internationalized/date";
|
|
import * as c from "@heroui-vue/components";
|
|
import { readFile } from "node:fs/promises";
|
|
for (const key of [
|
|
"DateField",
|
|
"DateFieldRoot",
|
|
"DateFieldGroup",
|
|
"DateFieldInput",
|
|
"DateFieldSegment",
|
|
"DateFieldPrefix",
|
|
"DateFieldSuffix",
|
|
"DateFieldInputContainer",
|
|
"DateInputGroup",
|
|
"DateInputGroupInput",
|
|
"DateInputGroupSegment",
|
|
"DateInputGroupInputContainer",
|
|
"DateInputGroupPrefix",
|
|
"DateInputGroupSuffix",
|
|
])
|
|
assert.ok(c[key], key);
|
|
const date = parseZonedDateTime(
|
|
"2024-03-10T01:30:45-08:00[America/Los_Angeles]",
|
|
);
|
|
const html = await renderToString(
|
|
createSSRApp({
|
|
render: () =>
|
|
h(
|
|
c.DateField,
|
|
{ defaultValue: date, granularity: "minute", name: "date" },
|
|
() => [
|
|
h(c.Label, () => "Date"),
|
|
h(c.DateFieldGroup, () => h(c.DateFieldInput)),
|
|
h(c.Description, () => "Help"),
|
|
],
|
|
),
|
|
}),
|
|
);
|
|
assert.ok(
|
|
html.includes('value="2024-03-10T01:30:45-08:00[America/Los_Angeles]"'),
|
|
);
|
|
assert.equal((html.match(/name="date"/g) || []).length, 1);
|
|
assert.ok(html.includes("aria-labelledby="));
|
|
assert.ok(html.includes("aria-describedby="));
|
|
const css = await readFile(
|
|
import.meta.resolve("@heroui-vue/styles/css").replace("file://", ""),
|
|
"utf8",
|
|
);
|
|
for (const name of [
|
|
"hv-date-field",
|
|
"hv-date-input-group",
|
|
"hv-date-input-group__segment",
|
|
"hv-date-input-group--secondary",
|
|
])
|
|
assert.ok(css.includes(name), name);
|
|
console.log("DateField tarball ESM/SSR/CSS: passed");
|