mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
test(ActionSheet): update test cases
This commit is contained in:
parent
0017c352b0
commit
00bc30c235
@ -1,5 +1,12 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`should allow to custom close icon with closeIcon prop 1`] = `
|
||||
<i class="van-badge__wrapper van-icon van-icon-cross van-action-sheet__close">
|
||||
<!---->
|
||||
<!---->
|
||||
<!----></i>
|
||||
`;
|
||||
|
||||
exports[`should render default slot and match snapshot 1`] = `
|
||||
<transition-stub>
|
||||
<div class="van-overlay">
|
||||
@ -20,3 +27,7 @@ exports[`should render default slot and match snapshot 1`] = `
|
||||
</div>
|
||||
</transition-stub>
|
||||
`;
|
||||
|
||||
exports[`should render description and match snapshot 1`] = `<div class="van-action-sheet__description">This is a description</div>`;
|
||||
|
||||
exports[`should render description slot when match snapshot 1`] = `<div class="van-action-sheet__description">Custom Description</div>`;
|
||||
|
@ -98,64 +98,3 @@ test('close-on-click-action prop', () => {
|
||||
|
||||
expect(onInput).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
test('color option', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: true,
|
||||
actions: [{ name: 'Option', color: 'red' }],
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('description prop', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: true,
|
||||
description: 'This is a description',
|
||||
actions: [{ name: 'Option' }],
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('description slot', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: true,
|
||||
actions: [{ name: 'Option' }],
|
||||
},
|
||||
scopedSlots: {
|
||||
description: () => 'Custom Description',
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('close-icon prop', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: true,
|
||||
title: 'Title',
|
||||
closeIcon: 'cross',
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('closeable prop', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: true,
|
||||
title: 'Title',
|
||||
closeable: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user