Skip to content

Commit 64853e2

Browse files
committed
test: add breadcrumb, meny and select tests
1 parent 607478a commit 64853e2

File tree

3 files changed

+365
-360
lines changed

3 files changed

+365
-360
lines changed

src/components/compounds/Breadcrumb/__tests__/Breadcrumb.spec.ts

Lines changed: 83 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,97 +6,103 @@ import Breadcrumb from "../Breadcrumb.vue";
66
import BreadcrumbItem from "../BreadcrumbItem.vue";
77

88
describe("Breadcrumb", () => {
9-
it("renders default breadcrumb", () => {
10-
const wrapper = mount(Breadcrumb, {
11-
slots: {
12-
default: () => [
13-
h(BreadcrumbItem, null, () => "Home"),
14-
h(BreadcrumbItem, null, () => "Components"),
15-
h(BreadcrumbItem, { active: true }, () => "Breadcrumb"),
16-
],
17-
},
18-
});
19-
20-
expect(wrapper.find("nav.breadcrumb").exists()).toBe(true);
21-
expect(wrapper.findAll("li").length).toBe(3);
22-
expect(wrapper.find("li.is-active").exists()).toBe(true);
23-
expect(wrapper.find("li.is-active").text()).toBe("Breadcrumb");
9+
it("renders default breadcrumb", () => {
10+
const wrapper = mount(Breadcrumb, {
11+
slots: {
12+
default: () => [
13+
h(BreadcrumbItem, null, () => "Home"),
14+
h(BreadcrumbItem, null, () => "Components"),
15+
h(BreadcrumbItem, { active: true }, () => "Breadcrumb"),
16+
],
17+
},
2418
});
2519

26-
it("applies alignment classes", () => {
27-
const centerWrapper = mount(Breadcrumb, { props: { alignment: "is-centered" } });
28-
expect(centerWrapper.find("nav.breadcrumb").classes()).toContain("is-centered");
20+
expect(wrapper.find("nav.breadcrumb").exists()).toBe(true);
21+
expect(wrapper.findAll("li").length).toBe(3);
22+
expect(wrapper.find("li.is-active").exists()).toBe(true);
23+
expect(wrapper.find("li.is-active").text()).toBe("Breadcrumb");
24+
});
2925

30-
const rightWrapper = mount(Breadcrumb, { props: { alignment: "is-right" } });
31-
expect(rightWrapper.find("nav.breadcrumb").classes()).toContain("is-right");
26+
it("applies alignment classes", () => {
27+
const centerWrapper = mount(Breadcrumb, {
28+
props: { alignment: "is-centered" },
3229
});
30+
expect(centerWrapper.find("nav.breadcrumb").classes()).toContain(
31+
"is-centered",
32+
);
3333

34-
it("applies separator classes", () => {
35-
const separators = [
36-
"has-arrow-separator",
37-
"has-bullet-separator",
38-
"has-dot-separator",
39-
"has-succeeds-separator",
40-
];
41-
for (const separator of separators) {
42-
const wrapper = mount(Breadcrumb, { props: { separator } });
43-
expect(wrapper.find("nav.breadcrumb").classes()).toContain(separator);
44-
}
34+
const rightWrapper = mount(Breadcrumb, {
35+
props: { alignment: "is-right" },
4536
});
37+
expect(rightWrapper.find("nav.breadcrumb").classes()).toContain("is-right");
38+
});
4639

47-
it("applies size classes", () => {
48-
const sizes = ["is-small", "is-medium", "is-large"];
49-
for (const size of sizes) {
50-
const wrapper = mount(Breadcrumb, { props: { size } });
51-
expect(wrapper.find("nav.breadcrumb").classes()).toContain(size);
52-
}
53-
});
40+
it("applies separator classes", () => {
41+
const separators = [
42+
"has-arrow-separator",
43+
"has-bullet-separator",
44+
"has-dot-separator",
45+
"has-succeeds-separator",
46+
];
47+
for (const separator of separators) {
48+
const wrapper = mount(Breadcrumb, { props: { separator } });
49+
expect(wrapper.find("nav.breadcrumb").classes()).toContain(separator);
50+
}
51+
});
52+
53+
it("applies size classes", () => {
54+
const sizes = ["is-small", "is-medium", "is-large"];
55+
for (const size of sizes) {
56+
const wrapper = mount(Breadcrumb, { props: { size } });
57+
expect(wrapper.find("nav.breadcrumb").classes()).toContain(size);
58+
}
59+
});
5460
});
5561

5662
describe("BreadcrumbItem", () => {
57-
it("renders default item with <a> tag", () => {
58-
const wrapper = mount(BreadcrumbItem, {
59-
slots: { default: () => "Link Item" },
60-
attrs: { href: "#test" },
61-
});
62-
const item = wrapper.find("li");
63-
const link = item.find("a");
64-
expect(item.exists()).toBe(true);
65-
expect(link.exists()).toBe(true);
66-
expect(link.text()).toBe("Link Item");
67-
expect(link.attributes("href")).toBe("#test");
68-
expect(item.classes()).not.toContain("is-active");
63+
it("renders default item with <a> tag", () => {
64+
const wrapper = mount(BreadcrumbItem, {
65+
slots: { default: () => "Link Item" },
66+
attrs: { href: "#test" },
6967
});
68+
const item = wrapper.find("li");
69+
const link = item.find("a");
70+
expect(item.exists()).toBe(true);
71+
expect(link.exists()).toBe(true);
72+
expect(link.text()).toBe("Link Item");
73+
expect(link.attributes("href")).toBe("#test");
74+
expect(item.classes()).not.toContain("is-active");
75+
});
7076

71-
it("renders item with custom tag", () => {
72-
const wrapper = mount(BreadcrumbItem, {
73-
props: { tag: "span" },
74-
slots: { default: () => "Span Item" },
75-
});
76-
const item = wrapper.find("li");
77-
expect(item.find("span").exists()).toBe(true);
78-
expect(item.find("span").text()).toBe("Span Item");
77+
it("renders item with custom tag", () => {
78+
const wrapper = mount(BreadcrumbItem, {
79+
props: { tag: "span" },
80+
slots: { default: () => "Span Item" },
7981
});
82+
const item = wrapper.find("li");
83+
expect(item.find("span").exists()).toBe(true);
84+
expect(item.find("span").text()).toBe("Span Item");
85+
});
8086

81-
it("renders active item", () => {
82-
const wrapper = mount(BreadcrumbItem, {
83-
props: { active: true },
84-
slots: { default: () => "Active Item" },
85-
});
86-
const item = wrapper.find("li");
87-
expect(item.classes()).toContain("is-active");
88-
expect(item.find("a").exists()).toBe(true);
89-
expect(item.text()).toBe("Active Item");
87+
it("renders active item", () => {
88+
const wrapper = mount(BreadcrumbItem, {
89+
props: { active: true },
90+
slots: { default: () => "Active Item" },
9091
});
92+
const item = wrapper.find("li");
93+
expect(item.classes()).toContain("is-active");
94+
expect(item.find("a").exists()).toBe(true);
95+
expect(item.text()).toBe("Active Item");
96+
});
9197

92-
it("renders active item with custom tag", () => {
93-
const wrapper = mount(BreadcrumbItem, {
94-
props: { active: true, tag: "p" },
95-
slots: { default: () => "Active Paragraph" },
96-
});
97-
const item = wrapper.find("li");
98-
expect(item.classes()).toContain("is-active");
99-
expect(item.find("p").exists()).toBe(true);
100-
expect(item.find("p").text()).toBe("Active Paragraph");
98+
it("renders active item with custom tag", () => {
99+
const wrapper = mount(BreadcrumbItem, {
100+
props: { active: true, tag: "p" },
101+
slots: { default: () => "Active Paragraph" },
101102
});
102-
});
103+
const item = wrapper.find("li");
104+
expect(item.classes()).toContain("is-active");
105+
expect(item.find("p").exists()).toBe(true);
106+
expect(item.find("p").text()).toBe("Active Paragraph");
107+
});
108+
});

0 commit comments

Comments
 (0)