test(ActionSheet): update some test cases

This commit is contained in:
chenjiahan
2020-11-11 23:17:36 +08:00
parent 37a38c887f
commit 21d52353ab
3 changed files with 71 additions and 51 deletions
+49
View 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();
});