[improvement] ContactCard: functional (#2696)

This commit is contained in:
neverland
2019-02-06 21:35:53 +08:00
committed by GitHub
parent 1b60e4df80
commit 3e0ac872c8
2 changed files with 35 additions and 18 deletions
+21 -5
View File
@@ -10,18 +10,34 @@ const contactInfo = {
describe('ContactCard', () => {
test('click event', () => {
const click = jest.fn();
const wrapper = mount(ContactCard, {
propsData: {
editable: false
context: {
on: {
click
}
}
});
wrapper.trigger('click');
expect(wrapper.emitted('click')).toBeFalsy();
expect(click.mock.calls.length).toEqual(1);
});
test('not editable', () => {
const click = jest.fn();
const wrapper = mount(ContactCard, {
propsData: {
editable: false
},
context: {
on: {
click
}
}
});
wrapper.setProps({ editable: true });
wrapper.trigger('click');
expect(wrapper.emitted('click')).toBeTruthy();
expect(click.mock.calls.length).toEqual(0);
});
});