[breaking change] Actionsheet: rename to ActionSheet

This commit is contained in:
陈嘉涵
2019-04-29 14:20:00 +08:00
parent fe89e18a24
commit b8424f8de9
19 changed files with 119 additions and 119 deletions

View File

@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders demo correctly 1`] = `
<div>
<div><button class="van-button van-button--default van-button--normal"><span class="van-button__text">弹出 ActionSheet</span></button>
<!---->
</div>
<div><button class="van-button van-button--default van-button--normal"><span class="van-button__text">弹出带取消按钮的 ActionSheet</span></button>
<!---->
</div>
<div><button class="van-button van-button--default van-button--normal"><span class="van-button__text">弹出带标题的 ActionSheet</span></button>
<!---->
</div>
</div>
`;

View File

@@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`callback events 1`] = `
<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-action-sheet__item--disabled van-hairline--top"><span class="van-action-sheet__name">Option</span></div>
<div class="van-action-sheet__cancel">Cancel</div>
</div>
`;
exports[`disable lazy-render 1`] = `
<div class="van-popup van-popup--bottom van-action-sheet" style="display: none;" 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__cancel">Cancel</div>
</div>
`;

View File

@@ -0,0 +1,4 @@
import Demo from '../demo';
import demoTest from '../../../test/demo-test';
demoTest(Demo);

View File

@@ -0,0 +1,66 @@
import { mount } from '../../../test/utils';
import ActionSheet from '..';
test('callback events', () => {
const callback = jest.fn();
const onInput = jest.fn();
const onCancel = jest.fn();
const onSelect = jest.fn();
const actions = [
{ name: 'Option', callback },
{ name: 'Option', disabled: true }
];
const wrapper = mount(ActionSheet, {
propsData: {
value: true,
actions,
cancelText: 'Cancel'
},
context: {
on: {
input: onInput,
cancel: onCancel,
select: onSelect
}
}
});
const options = wrapper.findAll('.van-action-sheet__item');
options.at(0).trigger('click');
options.at(1).trigger('click');
wrapper.find('.van-action-sheet__cancel').trigger('click');
expect(callback).toHaveBeenCalled();
expect(onCancel).toHaveBeenCalled();
expect(onInput).toHaveBeenCalledWith(false);
expect(onSelect).toHaveBeenCalledWith(actions[0], 0);
expect(wrapper).toMatchSnapshot();
});
test('disable lazy-render', () => {
const wrapper = mount(ActionSheet, {
propsData: {
lazyRender: false,
actions: [
{ name: 'Option' },
{ name: 'Option' }
],
cancelText: 'Cancel'
}
});
expect(wrapper).toMatchSnapshot();
});
test('get container', () => {
const wrapper = mount(ActionSheet, {
propsData: {
value: true,
getContainer: 'body'
}
});
expect(wrapper.vm.$el.parentNode).toEqual(document.body);
});