mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
25 lines
640 B
JavaScript
25 lines
640 B
JavaScript
import { mount } from '../../../test/utils';
|
|
import Actionsheet from '../';
|
|
|
|
test('callback events', () => {
|
|
const callback = jest.fn();
|
|
const wrapper = mount(Actionsheet, {
|
|
propsData: {
|
|
value: true,
|
|
actions: [
|
|
{ name: 'Option', callback },
|
|
{ name: 'Option' }
|
|
],
|
|
cancelText: 'Cancel'
|
|
}
|
|
});
|
|
|
|
wrapper.findAll('li').trigger('click');
|
|
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).toMatchSnapshot();
|
|
});
|