mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 15:09:16 +08:00
[improvement] ActionSheet: add test cases
This commit is contained in:
parent
cc36334625
commit
e8daae912a
@ -4,6 +4,10 @@ exports[`callback events 1`] = `
|
|||||||
<div class="van-popup van-popup--bottom van-action-sheet" name="van-popup-slide-bottom">
|
<div class="van-popup van-popup--bottom van-action-sheet" name="van-popup-slide-bottom">
|
||||||
<div class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></div>
|
<div class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></div>
|
||||||
<div class="van-action-sheet__item van-action-sheet__item--disabled van-hairline--top"><span class="van-action-sheet__name">Option</span></div>
|
<div class="van-action-sheet__item van-action-sheet__item--disabled van-hairline--top"><span class="van-action-sheet__name">Option</span></div>
|
||||||
|
<div class="van-action-sheet__item van-action-sheet__item--disabled van-hairline--top">
|
||||||
|
<div class="van-loading van-loading--circular"><span class="van-loading__spinner van-loading__spinner--circular" style="color: rgb(201, 201, 201); width: 20px; height: 20px;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span></div>
|
||||||
|
</div>
|
||||||
|
<div class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span><span class="van-action-sheet__subname">Subname</span></div>
|
||||||
<div class="van-action-sheet__cancel">Cancel</div>
|
<div class="van-action-sheet__cancel">Cancel</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -15,3 +19,5 @@ exports[`disable lazy-render 1`] = `
|
|||||||
<div class="van-action-sheet__cancel">Cancel</div>
|
<div class="van-action-sheet__cancel">Cancel</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`render title and default slot 1`] = ``;
|
||||||
|
@ -9,7 +9,9 @@ test('callback events', () => {
|
|||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{ name: 'Option', callback },
|
{ name: 'Option', callback },
|
||||||
{ name: 'Option', disabled: true }
|
{ name: 'Option', disabled: true },
|
||||||
|
{ name: 'Option', loading: true },
|
||||||
|
{ name: 'Option', subname: 'Subname' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
@ -39,6 +41,37 @@ test('callback events', () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('click overlay and close', () => {
|
||||||
|
const onInput = jest.fn();
|
||||||
|
const div = document.createElement('div');
|
||||||
|
|
||||||
|
mount({
|
||||||
|
template: `
|
||||||
|
<div>
|
||||||
|
<action-sheet
|
||||||
|
:value="true"
|
||||||
|
:get-container="getContainer"
|
||||||
|
@input="onInput"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
components: {
|
||||||
|
ActionSheet
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
getContainer: () => div
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onInput
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
div.querySelector('.van-overlay').click();
|
||||||
|
expect(onInput).toHaveBeenCalledWith(false);
|
||||||
|
});
|
||||||
|
|
||||||
test('disable lazy-render', () => {
|
test('disable lazy-render', () => {
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
propsData: {
|
propsData: {
|
||||||
@ -54,6 +87,21 @@ test('disable lazy-render', () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('render title and default slot', () => {
|
||||||
|
const wrapper = mount(ActionSheet, {
|
||||||
|
propsData: {
|
||||||
|
title: 'Title'
|
||||||
|
},
|
||||||
|
scopedSlots: {
|
||||||
|
default() {
|
||||||
|
return 'Default';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
test('get container', () => {
|
test('get container', () => {
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
propsData: {
|
propsData: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user