[improvement] Functional: ContactList, NavBar, Panel, SubmitBar, SwitchCell, Tag (#2675)

This commit is contained in:
neverland
2019-02-02 16:04:54 +08:00
committed by GitHub
parent 3c6c32e305
commit 5926d02d38
11 changed files with 302 additions and 265 deletions

View File

@@ -1,13 +1,20 @@
import SwitchCell from '..';
import { mount } from '../../../test/utils';
test('emit event', () => {
const wrapper = mount(SwitchCell);
test('change event', () => {
const onChange = jest.fn();
const wrapper = mount(SwitchCell, {
context: {
on: {
change: onChange
}
}
});
wrapper.vm.$on('input', value => {
wrapper.setProps({ value });
});
wrapper.find('.van-switch').trigger('click');
expect(wrapper.emitted('change')).toBeTruthy();
expect(onChange.mock.calls[0]).toBeTruthy();
});