From 634860544967fe564fa8d2b77fc3012d42b5af6b Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Fri, 27 Nov 2020 21:22:56 +0800 Subject: [PATCH] test(ContactCard): update test cases --- src/contact-card/test/index.legacy.js | 33 --------------------------- src/contact-card/test/index.spec.js | 19 +++++++++++++++ 2 files changed, 19 insertions(+), 33 deletions(-) delete mode 100644 src/contact-card/test/index.legacy.js create mode 100644 src/contact-card/test/index.spec.js diff --git a/src/contact-card/test/index.legacy.js b/src/contact-card/test/index.legacy.js deleted file mode 100644 index bc77c5561..000000000 --- a/src/contact-card/test/index.legacy.js +++ /dev/null @@ -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); -}); diff --git a/src/contact-card/test/index.spec.js b/src/contact-card/test/index.spec.js new file mode 100644 index 000000000..0bd871cbf --- /dev/null +++ b/src/contact-card/test/index.spec.js @@ -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(); +});