mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
test(ActionSheet): update some test cases
This commit is contained in:
parent
37a38c887f
commit
21d52353ab
22
src/action-sheet/test/__snapshots__/index.spec.js.snap
Normal file
22
src/action-sheet/test/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,22 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`should render default slot and match snapshot 1`] = `
|
||||
<transition-stub>
|
||||
<div class="van-overlay">
|
||||
<!---->
|
||||
</div>
|
||||
</transition-stub>
|
||||
<transition-stub>
|
||||
<div class="van-popup van-popup--round van-popup--bottom van-action-sheet">
|
||||
<div class="van-action-sheet__header">Title<i class="van-badge__wrapper van-icon van-icon-cross van-action-sheet__close">
|
||||
<!---->
|
||||
<!---->
|
||||
<!----></i></div>
|
||||
<!---->
|
||||
<div class="van-action-sheet__content">
|
||||
<!---->Default</div>
|
||||
<!---->
|
||||
<!---->
|
||||
</div>
|
||||
</transition-stub>
|
||||
`;
|
@ -78,45 +78,6 @@ test('click overlay and close', async () => {
|
||||
expect(onClickOverlay).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('disable lazy-render', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
lazyRender: false,
|
||||
actions: [{ name: 'Option' }, { name: 'Option' }],
|
||||
cancelText: 'Cancel',
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('render title and default slot', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: true,
|
||||
title: 'Title',
|
||||
},
|
||||
scopedSlots: {
|
||||
default() {
|
||||
return 'Default';
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('get container', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: true,
|
||||
teleport: 'body',
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.vm.$el.parentNode).toEqual(document.body);
|
||||
});
|
||||
|
||||
test('close-on-click-action prop', () => {
|
||||
const onInput = jest.fn();
|
||||
const wrapper = mount(ActionSheet, {
|
||||
@ -138,18 +99,6 @@ test('close-on-click-action prop', () => {
|
||||
expect(onInput).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
test('round prop', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
value: true,
|
||||
round: true,
|
||||
actions: [{ name: 'Option' }],
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('color option', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
|
49
src/action-sheet/test/index.spec.js
Normal file
49
src/action-sheet/test/index.spec.js
Normal file
@ -0,0 +1,49 @@
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { later } from '../../../test';
|
||||
import ActionSheet from '..';
|
||||
|
||||
test('should render content after disabling the lazy-render prop', async () => {
|
||||
const wrapper = mount(ActionSheet);
|
||||
expect(wrapper.find('.van-action-sheet__content').exists()).toBeFalsy();
|
||||
|
||||
wrapper.setProps({ lazyRender: false });
|
||||
await later();
|
||||
expect(wrapper.find('.van-action-sheet__content').exists()).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should render default slot and match snapshot', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
props: {
|
||||
show: true,
|
||||
title: 'Title',
|
||||
},
|
||||
slots: {
|
||||
default: () => 'Default',
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should allow to use the teleport prop', () => {
|
||||
const root = document.createElement('div');
|
||||
mount(ActionSheet, {
|
||||
propsData: {
|
||||
show: true,
|
||||
teleport: root,
|
||||
},
|
||||
});
|
||||
|
||||
expect(root.querySelector('.van-action-sheet')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should have "van-popup--round" class when setting the round prop', () => {
|
||||
const wrapper = mount(ActionSheet, {
|
||||
propsData: {
|
||||
show: true,
|
||||
round: true,
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.find('.van-popup--round').exists()).toBeTruthy();
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user