[improvement] Actionsheet: tsx (#2807)

This commit is contained in:
neverland
2019-02-20 15:55:02 +08:00
committed by GitHub
parent 9236132dbf
commit 52e6fd2f0b
4 changed files with 147 additions and 102 deletions
+15 -4
View File
@@ -3,6 +3,10 @@ import Actionsheet from '..';
test('callback events', () => {
const callback = jest.fn();
const onInput = jest.fn();
const onCancel = jest.fn();
const onSelect = jest.fn();
const wrapper = mount(Actionsheet, {
propsData: {
value: true,
@@ -11,6 +15,13 @@ test('callback events', () => {
{ name: 'Option', disabled: true }
],
cancelText: 'Cancel'
},
context: {
on: {
input: onInput,
cancel: onCancel,
select: onSelect
}
}
});
@@ -20,9 +31,9 @@ test('callback events', () => {
wrapper.find('.van-actionsheet__cancel').trigger('click');
expect(callback.mock.calls.length).toBe(1);
expect(wrapper.emitted('cancel')).toBeTruthy();
expect(wrapper.emitted('input')[0][0]).toBeFalsy();
expect(wrapper.emitted('select')[0][0]).toBeTruthy();
expect(wrapper.emitted('select')[0][1]).toBeFalsy();
expect(onCancel.mock.calls.length).toBeTruthy();
expect(onInput.mock.calls[0][0]).toBeFalsy();
expect(onSelect.mock.calls[0][0]).toBeTruthy();
expect(onSelect.mock.calls[0][1]).toBeFalsy();
expect(wrapper).toMatchSnapshot();
});