forked from Happy-Coding-Clans/vue-easytable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathve-icon.spec.js
64 lines (56 loc) · 1.7 KB
/
ve-icon.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { mount } from "@vue/test-utils";
import veIcon from "@/ve-icon";
import { later } from "../util";
describe("veIcon", () => {
it("render by different props", () => {
const wrapper = mount({
template: `
<div>
<ve-icon name="double-right-arrow" />
<ve-icon name="double-right-arrow" color="blue" />
<ve-icon name="double-right-arrow" :size="40" />
</div>`,
});
expect(wrapper.html()).toMatchSnapshot();
});
it("color prop", () => {
const wrapper = mount(veIcon, {
propsData: {
name: "double-right-arrow",
color: "red",
},
});
expect(wrapper.attributes("style")).toBe("color: red;");
});
it("font-size prop", () => {
const wrapper = mount(veIcon, {
propsData: {
name: "double-right-arrow",
size: 50,
},
});
expect(wrapper.attributes("style")).toBe("font-size: 50px;");
});
describe("warns", () => {
let errorSpy;
beforeEach(() => {
errorSpy = jest
.spyOn(console, "error")
.mockImplementation(() => {});
});
afterEach(() => {
errorSpy.mockRestore();
});
const errorIconName = "double-right-arrow2";
it("warning on error icon name", () => {
const wrapper = mount(veIcon, {
propsData: {
name: errorIconName,
},
});
expect(errorSpy).toBeCalledWith(
`${errorIconName} is not found in VeIcon.`,
);
});
});
});