Skip to content

Commit 1f7729e

Browse files
committed
test(UT): add more UT
1 parent 56cd494 commit 1f7729e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tests/unit/drawer.spec.js

+68
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,72 @@ describe("Drawer.vue", () => {
3838
expect(wrapper.find(".vue-simple-drawer").isVisible()).toBeTruthy();
3939
expect(wrapper.find(".mask").exists()).not.toBeTruthy();
4040
});
41+
42+
it("renders props with close event", () => {
43+
const wrapper = shallowMount(Drawer, {
44+
propsData: { mask: false, closeable: true, maskClosable: true },
45+
slots: {
46+
default: "<div>hello</div>"
47+
}
48+
});
49+
const stub = jest.fn();
50+
wrapper.vm.$on("close", stub);
51+
wrapper.find(".close-btn").trigger("click");
52+
expect(stub).toHaveBeenCalled();
53+
});
54+
55+
it("renders props with close by mask event", () => {
56+
const wrapper = shallowMount(Drawer, {
57+
propsData: { mask: true, closeable: true, maskClosable: true },
58+
slots: {
59+
default: "<div>hello</div>"
60+
}
61+
});
62+
const stub = jest.fn();
63+
wrapper.vm.$on("close", stub);
64+
wrapper.find(".mask").trigger("click");
65+
expect(stub).toHaveBeenCalled();
66+
});
67+
68+
it("renders props with maskClosable as false", () => {
69+
const wrapper = shallowMount(Drawer, {
70+
propsData: { mask: true, closeable: true, maskClosable: false },
71+
slots: {
72+
default: "<div>hello</div>"
73+
}
74+
});
75+
const stub = jest.fn();
76+
wrapper.vm.$on("close", stub);
77+
wrapper.find(".mask").trigger("click");
78+
expect(stub).not.toHaveBeenCalled();
79+
});
80+
81+
it("renders props with zIndex as 10002", () => {
82+
const wrapper = shallowMount(Drawer, {
83+
propsData: {
84+
mask: true,
85+
closeable: true,
86+
maskClosable: false,
87+
zIndex: 10002
88+
},
89+
slots: {
90+
default: "<div>hello</div>"
91+
}
92+
});
93+
expect(wrapper.vm.computedIndex).toEqual(10002);
94+
});
95+
96+
it("renders props with zIndex as default", () => {
97+
const wrapper = shallowMount(Drawer, {
98+
propsData: {
99+
mask: true,
100+
closeable: true,
101+
maskClosable: false
102+
},
103+
slots: {
104+
default: "<div>hello</div>"
105+
}
106+
});
107+
expect(wrapper.vm.computedIndex).toEqual(1000);
108+
});
41109
});

0 commit comments

Comments
 (0)