feat: establish shared calendar range selection foundation
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// @vitest-environment node
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { createSSRApp, defineComponent, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { CalendarDate, parseZonedDateTime } from "@internationalized/date";
|
||||
import Range from "../packages/vue/tests/fixtures/RangeCalendarFoundation.vue";
|
||||
describe("range foundation actual node SSR", () => {
|
||||
it("renders complete semantic ranges, namespace and closed year layer without browser globals", async () => {
|
||||
const start = new CalendarDate(2024, 2, 10),
|
||||
end = start.add({ days: 3 });
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(Range, {
|
||||
defaultValue: { start, end },
|
||||
timeZone: "UTC",
|
||||
"aria-label": "Trip dates",
|
||||
}),
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain('data-slot="range-calendar-grid"');
|
||||
expect(html).toContain('role="grid"');
|
||||
expect(html).toContain('data-selection-start="true"');
|
||||
expect(html).toContain('data-selection-end="true"');
|
||||
expect(html).toContain('aria-hidden="true" inert');
|
||||
expect(html).not.toContain('name="');
|
||||
});
|
||||
it("retains full zoned accepted endpoints while rendering a locale-specific leap month", async () => {
|
||||
const start = parseZonedDateTime(
|
||||
"2024-02-28T13:14:45.123-08:00[America/Los_Angeles]",
|
||||
),
|
||||
end = start.add({ days: 2 });
|
||||
const html = await renderToString(
|
||||
createSSRApp(
|
||||
defineComponent({
|
||||
render: () =>
|
||||
h(Range, {
|
||||
defaultValue: { start, end },
|
||||
locale: "fa-IR-u-ca-persian",
|
||||
timeZone: "America/Los_Angeles",
|
||||
visibleDuration: { weeks: 2 },
|
||||
}),
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(html).toContain("hv-range-calendar--week-view");
|
||||
expect(html).toContain('data-selected="true"');
|
||||
expect(html).not.toContain("Invalid Date");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user