mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
27 lines
700 B
JavaScript
27 lines
700 B
JavaScript
import { shallow } from '@vue/test-utils';
|
|
import Actionsheet from '../';
|
|
import demoTest from '../../../test/demo-test';
|
|
|
|
demoTest(Actionsheet);
|
|
|
|
test('callback events', () => {
|
|
const callback = jest.fn();
|
|
const wrapper = shallow(Actionsheet, {
|
|
propsData: {
|
|
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.html()).toMatchSnapshot();
|
|
});
|