feat: add Disclosure DisclosureGroup and Accordion
This commit is contained in:
@@ -295,3 +295,54 @@ it("renders progress and meter indicators without browser globals", async () =>
|
||||
expect(html).toMatch(new RegExp(`id="${id}"[^>]*data-slot="label"`));
|
||||
}
|
||||
});
|
||||
|
||||
it("renders disclosure group and accordion without browser globals", async () => {
|
||||
const {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
Disclosure,
|
||||
DisclosureContent,
|
||||
DisclosureGroup,
|
||||
DisclosureHeading,
|
||||
DisclosureTrigger,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("div", {}, [
|
||||
h(DisclosureGroup, { defaultExpandedKeys: ["a"] }, () => [
|
||||
h(Disclosure, { id: "a" }, () => [
|
||||
h(DisclosureHeading, {}, () =>
|
||||
h(DisclosureTrigger, {}, () => "标题A"),
|
||||
),
|
||||
h(DisclosureContent, {}, () => "内容A"),
|
||||
]),
|
||||
]),
|
||||
h(Accordion, { defaultExpandedKeys: ["x"] }, () => [
|
||||
h(AccordionItem, { id: "x" }, () => [
|
||||
h(AccordionHeading, {}, () =>
|
||||
h(AccordionTrigger, {}, () => "手风琴"),
|
||||
),
|
||||
h(AccordionPanel, {}, () => h(AccordionBody, {}, () => "正文")),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('data-slot="disclosure-group"');
|
||||
expect(html).toContain('aria-expanded="true"');
|
||||
expect(html).toContain('data-slot="accordion-item"');
|
||||
expect(html).toContain("正文");
|
||||
const controls = [...html.matchAll(/aria-controls="([^"]+)"/g)].map(
|
||||
(m) => m[1],
|
||||
);
|
||||
expect(controls.length).toBeGreaterThan(0);
|
||||
for (const id of controls) {
|
||||
expect(html).toContain(`id="${id}"`);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user