From b3580184f507e4e0b95ad6cca88a455f92bc04db Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 24 Nov 2021 17:44:59 +0100 Subject: [PATCH] test creation confirm --- admin/src/views/CreationConfirm.spec.js | 53 +++++++++++++++++++++++++ admin/src/views/CreationConfirm.vue | 4 +- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 admin/src/views/CreationConfirm.spec.js diff --git a/admin/src/views/CreationConfirm.spec.js b/admin/src/views/CreationConfirm.spec.js new file mode 100644 index 000000000..caf94cd37 --- /dev/null +++ b/admin/src/views/CreationConfirm.spec.js @@ -0,0 +1,53 @@ +import { mount } from '@vue/test-utils' +import CreationConfirm from './CreationConfirm.vue' + +const localVue = global.localVue + +const storeCommitMock = jest.fn() + +const mocks = { + $store: { + commit: storeCommitMock, + }, +} + +describe('CreationConfirm', () => { + let wrapper + + const Wrapper = () => { + return mount(CreationConfirm, { localVue, mocks }) + } + + describe('mount', () => { + beforeEach(() => { + jest.clearAllMocks() + wrapper = Wrapper() + }) + + it('has a DIV element with the class.creation-confirm', () => { + expect(wrapper.find('div.creation-confirm').exists()).toBeTruthy() + }) + + describe('store', () => { + it('commits resetOpenCreations to store', () => { + expect(storeCommitMock).toBeCalledWith('resetOpenCreations') + }) + + it('commits openCreationsPlus to store', () => { + expect(storeCommitMock).toBeCalledWith('openCreationsPlus', 5) + }) + }) + + describe('confirm creation', () => { + beforeEach(async () => { + await wrapper + .findComponent({ name: 'UserTable' }) + .vm.$emit('remove-confirm-result', 1, 'remove') + }) + + it('commits openCreationsMinus to store', () => { + expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1) + }) + }) + }) +}) diff --git a/admin/src/views/CreationConfirm.vue b/admin/src/views/CreationConfirm.vue index 83ba54552..0d68635e0 100644 --- a/admin/src/views/CreationConfirm.vue +++ b/admin/src/views/CreationConfirm.vue @@ -1,5 +1,5 @@