Files
heroui-vue/tests/calendar-demos.test.ts
T

33 lines
1.1 KiB
TypeScript

import { afterEach, expect, it, vi } from "vitest";
import { mount, flushPromises } from "@vue/test-utils";
import { defineComponent, h, type Component } from "vue";
const demos = import.meta.glob("../apps/docs/demos/calendar-*.vue", {
eager: true,
import: "default",
}) as Record<string, Component>;
const wrappers: ReturnType<typeof mount>[] = [];
afterEach(() => {
wrappers.splice(0).forEach((w) => w.unmount());
document.body.innerHTML = "";
vi.restoreAllMocks();
});
it("mounts all nineteen baseline demos together without duplicate IDs or Vue warnings", async () => {
expect(Object.keys(demos)).toHaveLength(19);
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
const w = mount(
defineComponent({
render: () =>
h(
"div",
Object.entries(demos).map(([key, demo]) => h(demo, { key })),
),
}),
{ attachTo: document.body },
);
wrappers.push(w);
await flushPromises();
const ids = Array.from(document.querySelectorAll("[id]")).map((e) => e.id);
expect(new Set(ids).size).toBe(ids.length);
expect(warn).not.toHaveBeenCalled();
});