vant/packages/switch/test/index.spec.js
2019-02-14 13:58:07 +08:00

41 lines
799 B
JavaScript

import Switch from '..';
import { mount } from '../../../test/utils';
test('emit event', () => {
const input = jest.fn();
const change = jest.fn();
const wrapper = mount(Switch, {
context: {
on: {
input,
change
}
}
});
wrapper.trigger('click');
wrapper.trigger('click');
expect(input.mock.calls).toEqual([[true], [true]]);
expect(change.mock.calls).toEqual([[true], [true]]);
});
test('disabled', () => {
const input = jest.fn();
const change = jest.fn();
const wrapper = mount(Switch, {
context: {
on: {
input,
change
}
},
propsData: {
disabled: true
}
});
wrapper.trigger('click');
expect(input.mock.calls.length).toBeFalsy();
expect(change.mock.calls.length).toBeFalsy();
});