Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Commit 2782a84

Browse files
authored
feat: add tests for Label component (#214)
1 parent c047c26 commit 2782a84

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { mount } from "@vue/test-utils";
2+
import Label from "../Label.vue";
3+
4+
describe("Label", () => {
5+
it("renders correctly", () => {
6+
const wrapper = mount(Label, {
7+
propsData: {
8+
type: "warning"
9+
},
10+
slots: {
11+
default: "Label"
12+
}
13+
});
14+
expect(wrapper.element).toMatchSnapshot();
15+
});
16+
17+
it("renders correct types", () => {
18+
const labelWarning = mount(Label, {
19+
propsData: {
20+
type: "warning"
21+
},
22+
slots: {
23+
default: "Label"
24+
}
25+
});
26+
const labelError = mount(Label, {
27+
propsData: {
28+
type: "error"
29+
},
30+
slots: {
31+
default: "Label"
32+
}
33+
});
34+
const labelSuccess = mount(Label, {
35+
propsData: {
36+
type: "success"
37+
},
38+
slots: {
39+
default: "Label"
40+
}
41+
});
42+
43+
expect(labelWarning.classes('fd-label--warning')).toBe(true);
44+
expect(labelError.classes('fd-label--error')).toBe(true);
45+
expect(labelSuccess.classes('fd-label--success')).toBe(true);
46+
});
47+
48+
it("renders default slot when passed", () => {
49+
const label = "Label";
50+
const wrapper = mount(Label, {
51+
slots: {
52+
default: label
53+
}
54+
});
55+
expect(wrapper.text()).toEqual(label);
56+
});
57+
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Label renders correctly 1`] = `
4+
<span
5+
class="fd-label fd-label--warning"
6+
>
7+
Label
8+
</span>
9+
`;

0 commit comments

Comments
 (0)