From 1f0bea76c5b71156afecfc66df91a3588577eeac Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 31 Aug 2022 11:37:48 +0200 Subject: [PATCH] change tests --- .../ContributionMessagesFormular.spec.js | 25 ++++++++++++++++--- .../ContributionMessagesListItem.spec.js | 1 + .../slots/IsModerator.spec.js | 1 + .../slots/IsNotModerator.spec.js | 1 + .../ContributionMessagesFormular.spec.js | 25 ++++++++++++++++--- .../ContributionMessagesListItem.spec.js | 1 + .../slots/IsModerator.spec.js | 1 + .../slots/IsNotModerator.spec.js | 1 + frontend/src/pages/Community.spec.js | 4 --- 9 files changed, 48 insertions(+), 12 deletions(-) diff --git a/admin/src/components/ContributionMessages/ContributionMessagesFormular.spec.js b/admin/src/components/ContributionMessages/ContributionMessagesFormular.spec.js index a29b3df08..62fcab505 100644 --- a/admin/src/components/ContributionMessages/ContributionMessagesFormular.spec.js +++ b/admin/src/components/ContributionMessages/ContributionMessagesFormular.spec.js @@ -40,7 +40,7 @@ describe('ContributionMessagesFormular', () => { expect(wrapper.find('div.contribution-messages-formular').exists()).toBe(true) }) - describe('call onReset', () => { + describe('on trigger reset', () => { beforeEach(async () => { wrapper.setData({ form: { @@ -50,17 +50,34 @@ describe('ContributionMessagesFormular', () => { await wrapper.find('form').trigger('reset') }) - it('form has the set data', () => { + it('form has empty text', () => { expect(wrapper.vm.form).toEqual({ text: '', }) }) }) - describe('call onSubmit', () => { - it('response with the contribution message', async () => { + describe('on trigger submit', () => { + beforeEach(async () => { + wrapper.setData({ + form: { + text: 'text form message', + }, + }) await wrapper.find('form').trigger('submit') }) + + it('emitted "get-list-contribution-messages" with data', async () => { + expect(wrapper.emitted('get-list-contribution-messages')).toEqual( + expect.arrayContaining([expect.arrayContaining([42])]), + ) + }) + + it('emitted "update-state" with data', async () => { + expect(wrapper.emitted('update-state')).toEqual( + expect.arrayContaining([expect.arrayContaining([42])]), + ) + }) }) describe('send contribution message with error', () => { diff --git a/admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.spec.js b/admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.spec.js index 4c12a4f59..7cca315d7 100644 --- a/admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.spec.js +++ b/admin/src/components/ContributionMessages/slots/ContributionMessagesListItem.spec.js @@ -8,6 +8,7 @@ describe('ContributionMessagesListItem', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), $store: { state: { moderator: { diff --git a/admin/src/components/ContributionMessages/slots/IsModerator.spec.js b/admin/src/components/ContributionMessages/slots/IsModerator.spec.js index b9706b543..b1e09da94 100644 --- a/admin/src/components/ContributionMessages/slots/IsModerator.spec.js +++ b/admin/src/components/ContributionMessages/slots/IsModerator.spec.js @@ -8,6 +8,7 @@ describe('IsModerator', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), } const propsData = { diff --git a/admin/src/components/ContributionMessages/slots/IsNotModerator.spec.js b/admin/src/components/ContributionMessages/slots/IsNotModerator.spec.js index 434736993..24152ad1e 100644 --- a/admin/src/components/ContributionMessages/slots/IsNotModerator.spec.js +++ b/admin/src/components/ContributionMessages/slots/IsNotModerator.spec.js @@ -8,6 +8,7 @@ describe('IsNotModerator', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), } const propsData = { diff --git a/frontend/src/components/ContributionMessages/ContributionMessagesFormular.spec.js b/frontend/src/components/ContributionMessages/ContributionMessagesFormular.spec.js index a608035a8..aba5abc34 100644 --- a/frontend/src/components/ContributionMessages/ContributionMessagesFormular.spec.js +++ b/frontend/src/components/ContributionMessages/ContributionMessagesFormular.spec.js @@ -40,7 +40,7 @@ describe('ContributionMessagesFormular', () => { expect(wrapper.find('div.contribution-messages-formular').exists()).toBe(true) }) - describe('call onReset', () => { + describe('on trigger reset', () => { beforeEach(async () => { wrapper.setData({ form: { @@ -50,17 +50,34 @@ describe('ContributionMessagesFormular', () => { await wrapper.find('form').trigger('reset') }) - it('form has the set data', () => { + it('form has empty text', () => { expect(wrapper.vm.form).toEqual({ text: '', }) }) }) - describe('call onSubmit', () => { - it('response with the contribution message', async () => { + describe('on trigger submit', () => { + beforeEach(async () => { + wrapper.setData({ + form: { + text: 'text form message', + }, + }) await wrapper.find('form').trigger('submit') }) + + it('emitted "get-list-contribution-messages" with data', async () => { + expect(wrapper.emitted('get-list-contribution-messages')).toEqual( + expect.arrayContaining([expect.arrayContaining([42])]), + ) + }) + + it('emitted "update-state" with data', async () => { + expect(wrapper.emitted('update-state')).toEqual( + expect.arrayContaining([expect.arrayContaining([42])]), + ) + }) }) describe('send contribution message with error', () => { diff --git a/frontend/src/components/ContributionMessages/ContributionMessagesListItem.spec.js b/frontend/src/components/ContributionMessages/ContributionMessagesListItem.spec.js index 0de18778f..b9f6f0029 100644 --- a/frontend/src/components/ContributionMessages/ContributionMessagesListItem.spec.js +++ b/frontend/src/components/ContributionMessages/ContributionMessagesListItem.spec.js @@ -8,6 +8,7 @@ describe('ContributionMessagesList', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), $store: { state: { firstName: 'Peter', diff --git a/frontend/src/components/ContributionMessages/slots/IsModerator.spec.js b/frontend/src/components/ContributionMessages/slots/IsModerator.spec.js index b9706b543..b1e09da94 100644 --- a/frontend/src/components/ContributionMessages/slots/IsModerator.spec.js +++ b/frontend/src/components/ContributionMessages/slots/IsModerator.spec.js @@ -8,6 +8,7 @@ describe('IsModerator', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), } const propsData = { diff --git a/frontend/src/components/ContributionMessages/slots/IsNotModerator.spec.js b/frontend/src/components/ContributionMessages/slots/IsNotModerator.spec.js index 434736993..24152ad1e 100644 --- a/frontend/src/components/ContributionMessages/slots/IsNotModerator.spec.js +++ b/frontend/src/components/ContributionMessages/slots/IsNotModerator.spec.js @@ -8,6 +8,7 @@ describe('IsNotModerator', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), } const propsData = { diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index b4aa43785..781277e31 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -92,10 +92,6 @@ describe('Community', () => { it('has three tabs', () => { expect(wrapper.findAll('div[role="tabpanel"]')).toHaveLength(3) }) - - it('has first tab active by default', () => { - expect(wrapper.findAll('div[role="tabpanel"]').at(0).classes('active')).toBe(true) - }) }) describe('API calls after creation', () => {