diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index caf94cd37..365ccd809 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -4,11 +4,42 @@ import CreationConfirm from './CreationConfirm.vue' const localVue = global.localVue const storeCommitMock = jest.fn() +const toastedErrorMock = jest.fn() +const apolloQueryMock = jest.fn().mockResolvedValue({ + data: { + getPendingCreations: [ + { + firstName: 'Bibi', + lastName: 'Bloxberg', + email: 'bibi@bloxberg.de', + amount: 500, + note: 'Danke für alles', + date: new Date(), + moderator: 0, + }, + { + firstName: 'Räuber', + lastName: 'Hotzenplotz', + email: 'raeuber@hotzenplotz.de', + amount: 1000000, + note: 'Gut Ergatert', + date: new Date(), + moderator: 0, + }, + ], + }, +}) const mocks = { $store: { commit: storeCommitMock, }, + $apollo: { + query: apolloQueryMock, + }, + $toasted: { + error: toastedErrorMock, + }, } describe('CreationConfirm', () => { @@ -29,12 +60,22 @@ describe('CreationConfirm', () => { }) describe('store', () => { - it('commits resetOpenCreations to store', () => { - expect(storeCommitMock).toBeCalledWith('resetOpenCreations') + it('commits openCreationsPlus to store', () => { + expect(storeCommitMock).toBeCalledWith('openCreationsPlus', 2) + }) + }) + + describe('server response is error', () => { + beforeEach(() => { + jest.clearAllMocks() + apolloQueryMock.mockRejectedValue({ + message: 'Ouch!', + }) + wrapper = Wrapper() }) - it('commits openCreationsPlus to store', () => { - expect(storeCommitMock).toBeCalledWith('openCreationsPlus', 5) + it('toast an error message', () => { + expect(toastedErrorMock).toBeCalledWith('Ouch!') }) })