test(ActionSheet): update test cases
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user