Removed the remove test that removes all creations, Test that the server sends error.

This commit is contained in:
elweyn 2021-11-30 09:28:59 +01:00
parent 5a3fb2bd80
commit da649868cc

View File

@ -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!')
})
})