From f8b449e6235d7348e6fc682156fe060034e28904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 20 Jun 2022 13:30:48 +0200 Subject: [PATCH] Refine the tests after Moriz suggestions --- .../components/ChangeUserRoleFormular.spec.js | 19 ++++----- .../src/components/Tables/SearchUserTable.vue | 7 +++- admin/src/pages/UserSearch.spec.js | 39 ++++++++++++------- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/admin/src/components/ChangeUserRoleFormular.spec.js b/admin/src/components/ChangeUserRoleFormular.spec.js index ccb5c0587..8bcd4d8e5 100644 --- a/admin/src/components/ChangeUserRoleFormular.spec.js +++ b/admin/src/components/ChangeUserRoleFormular.spec.js @@ -5,11 +5,9 @@ import { toastSuccessSpy, toastErrorSpy } from '../../test/testSetup' const localVue = global.localVue -const date = new Date() - const apolloMutateMock = jest.fn().mockResolvedValue({ data: { - setUserRole: date, + setUserRole: null, }, }) @@ -68,7 +66,7 @@ describe('ChangeUserRoleFormular', () => { wrapper = Wrapper() }) - it('shows a text that you cannot change own role', () => { + it('has the text that you cannot change own role', () => { expect(wrapper.text()).toContain('userRole.notChangeYourSelf') }) @@ -92,11 +90,11 @@ describe('ChangeUserRoleFormular', () => { rolesToSelect = wrapper.find('select.role-select').findAll('option') }) - it('shows no text that you cannot change own role', () => { + it('has no text that you cannot change own role', () => { expect(wrapper.text()).not.toContain('userRole.notChangeYourSelf') }) - it('shows the select label', () => { + it('has the select label', () => { expect(wrapper.text()).toContain('userRole.selectLabel') }) @@ -109,10 +107,9 @@ describe('ChangeUserRoleFormular', () => { }) describe('on API error', () => { - beforeEach(async () => { + beforeEach(() => { apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) rolesToSelect.at(1).setSelected() - await wrapper.vm.$nextTick() }) it('toasts an error message', () => { @@ -125,7 +122,7 @@ describe('ChangeUserRoleFormular', () => { beforeEach(() => { apolloMutateMock.mockResolvedValue({ data: { - setUserRole: date, + setUserRole: new Date(), }, }) propsData = { @@ -173,7 +170,7 @@ describe('ChangeUserRoleFormular', () => { expect.arrayContaining([ { userId: 1, - isAdmin: date, + isAdmin: expect.any(Date), }, ]), ]), @@ -197,7 +194,7 @@ describe('ChangeUserRoleFormular', () => { propsData = { item: { userId: 1, - isAdmin: date, + isAdmin: new Date(), }, } wrapper = Wrapper() diff --git a/admin/src/components/Tables/SearchUserTable.vue b/admin/src/components/Tables/SearchUserTable.vue index 973817dcf..772160202 100644 --- a/admin/src/components/Tables/SearchUserTable.vue +++ b/admin/src/components/Tables/SearchUserTable.vue @@ -18,7 +18,7 @@