mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
test(ContactCard): update test cases
This commit is contained in:
parent
fac2b08ec2
commit
6348605449
@ -1,33 +0,0 @@
|
|||||||
import ContactCard from '..';
|
|
||||||
import { mount } from '@vue/test-utils';
|
|
||||||
|
|
||||||
test('should emit click event after clicking the ContactCard', () => {
|
|
||||||
const click = jest.fn();
|
|
||||||
const wrapper = mount(ContactCard, {
|
|
||||||
context: {
|
|
||||||
on: {
|
|
||||||
click,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
wrapper.trigger('click');
|
|
||||||
expect(click).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should not emit click event after clicking the uneditable ContactCard', () => {
|
|
||||||
const click = jest.fn();
|
|
||||||
const wrapper = mount(ContactCard, {
|
|
||||||
props: {
|
|
||||||
editable: false,
|
|
||||||
},
|
|
||||||
context: {
|
|
||||||
on: {
|
|
||||||
click,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
wrapper.trigger('click');
|
|
||||||
expect(click).toHaveBeenCalledTimes(0);
|
|
||||||
});
|
|
19
src/contact-card/test/index.spec.js
Normal file
19
src/contact-card/test/index.spec.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import ContactCard from '..';
|
||||||
|
import { mount } from '@vue/test-utils';
|
||||||
|
|
||||||
|
test('should emit click event when clicked', () => {
|
||||||
|
const wrapper = mount(ContactCard);
|
||||||
|
wrapper.trigger('click');
|
||||||
|
expect(wrapper.emitted('click').length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not emit click event when editable is false and clicked ', () => {
|
||||||
|
const wrapper = mount(ContactCard, {
|
||||||
|
props: {
|
||||||
|
editable: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
wrapper.trigger('click');
|
||||||
|
expect(wrapper.emitted('click')).toBeFalsy();
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user