diff --git a/app/javascript/dashboard/routes/dashboard/contacts/components/specs/AddReminder.spec.js b/app/javascript/dashboard/routes/dashboard/contacts/components/specs/AddReminder.spec.js new file mode 100644 index 000000000..e99fdb9ff --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/contacts/components/specs/AddReminder.spec.js @@ -0,0 +1,48 @@ +import { shallowMount } from '@vue/test-utils'; +import AddReminder from '../AddReminder.vue'; + +let wrapper; + +describe('AddReminder', () => { + beforeEach(() => { + wrapper = shallowMount(AddReminder, { + mocks: { + $t: x => x, + $store: { + getters: {}, + state: {}, + }, + }, + }); + }); + + it('tests resetValue', () => { + const resetValue = jest.spyOn(wrapper.vm, 'resetValue'); + wrapper.vm.content = 'test'; + wrapper.vm.date = '08/11/2022'; + wrapper.vm.resetValue(); + expect(wrapper.vm.content).toEqual(''); + expect(wrapper.vm.date).toEqual(''); + expect(resetValue).toHaveBeenCalled(); + }); + + it('tests optionSelected', () => { + const optionSelected = jest.spyOn(wrapper.vm, 'optionSelected'); + wrapper.vm.label = ''; + wrapper.vm.optionSelected({ target: { value: 'test' } }); + expect(wrapper.vm.label).toEqual('test'); + expect(optionSelected).toHaveBeenCalled(); + }); + + it('tests onAdd', () => { + const onAdd = jest.spyOn(wrapper.vm, 'onAdd'); + wrapper.vm.label = 'label'; + wrapper.vm.content = 'content'; + wrapper.vm.date = '08/11/2022'; + wrapper.vm.onAdd(); + expect(onAdd).toHaveBeenCalled(); + expect(wrapper.emitted().add[0]).toEqual([ + { content: 'content', date: '08/11/2022', label: 'label' }, + ]); + }); +}); diff --git a/jest.config.js b/jest.config.js index 135098515..604b5f694 100644 --- a/jest.config.js +++ b/jest.config.js @@ -15,7 +15,7 @@ module.exports = { cacheDirectory: '/.jest-cache', collectCoverage: false, coverageDirectory: 'buildreports', - collectCoverageFrom: ['**/app/javascript/**/*.js'], + collectCoverageFrom: ['**/app/javascript/**/*.{js,vue}'], reporters: ['default'], // setupTestFrameworkScriptFile: './tests/setup.ts', transformIgnorePatterns: ['node_modules/*'],