[improvement] Actionsheet: tsx (#2807)
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user