test(ActionSheet): update test cases

This commit is contained in:
chenjiahan
2020-11-13 14:14:27 +08:00
parent 0017c352b0
commit 00bc30c235
3 changed files with 79 additions and 61 deletions
+68
View File
@@ -47,3 +47,71 @@ test('should have "van-popup--round" class when setting the round prop', () => {
expect(wrapper.find('.van-popup--round').exists()).toBeTruthy();
});
test('should change option color when using the color prop', () => {
const wrapper = mount(ActionSheet, {
propsData: {
show: true,
actions: [{ name: 'Option', color: 'red' }],
},
});
expect(wrapper.find('.van-action-sheet__item').element.style.color).toEqual(
'red'
);
});
test('should hide close icon when the closeable prop is false', async () => {
const wrapper = mount(ActionSheet, {
propsData: {
show: true,
title: 'Title',
},
});
expect(wrapper.find('.van-action-sheet__close').exists()).toBeTruthy();
wrapper.setProps({ closeable: false });
await later();
expect(wrapper.find('.van-action-sheet__close').exists()).toBeFalsy();
});
test('should allow to custom close icon with closeIcon prop', () => {
const wrapper = mount(ActionSheet, {
propsData: {
show: true,
title: 'Title',
closeIcon: 'cross',
},
});
expect(wrapper.find('.van-action-sheet__close').html()).toMatchSnapshot();
});
test('should render description and match snapshot', () => {
const wrapper = mount(ActionSheet, {
propsData: {
show: true,
description: 'This is a description',
},
});
expect(
wrapper.find('.van-action-sheet__description').html()
).toMatchSnapshot();
});
test('should render description slot when match snapshot', () => {
const wrapper = mount(ActionSheet, {
propsData: {
show: true,
},
slots: {
description: () => 'Custom Description',
},
});
expect(
wrapper.find('.van-action-sheet__description').html()
).toMatchSnapshot();
});