Adding tests for CreationFormular and EditCreationFormular.

This commit is contained in:
elweyn 2021-12-30 12:35:52 +01:00
parent 0a57d882c6
commit 0d431974bd
2 changed files with 35 additions and 7 deletions

View File

@ -98,7 +98,10 @@ describe('CreationFormular', () => {
describe('with mass creation', () => {
beforeEach(async () => {
jest.clearAllMocks()
await wrapper.setProps({ type: 'massCreation' })
await wrapper.setProps({ type: 'massCreation', creation: [200, 400, 600] })
await wrapper.setData({ rangeMin: 180 })
await wrapper.setData({ text: 'Test create coins' })
await wrapper.setData({ value: 90 })
})
describe('first radio button', () => {

View File

@ -16,6 +16,7 @@ const apolloMutateMock = jest.fn().mockResolvedValue({
const stateCommitMock = jest.fn()
const toastedErrorMock = jest.fn()
const toastedSuccessMock = jest.fn()
const mocks = {
$moment: jest.fn(() => {
@ -42,6 +43,7 @@ const mocks = {
},
$toasted: {
error: toastedErrorMock,
success: toastedSuccessMock,
},
}
@ -52,6 +54,10 @@ const propsData = {
amount: 100,
date: '2021-12-01',
},
item: {
id: 0,
email: 'bob@baumeister.de',
},
}
describe('EditCreationFormular', () => {
@ -108,8 +114,8 @@ describe('EditCreationFormular', () => {
variables: {
amount: 90,
creationDate: 'YYYY-MM-01',
email: undefined,
id: undefined,
email: 'bob@baumeister.de',
id: 0,
memo: 'Test create coins',
moderator: 0,
},
@ -117,6 +123,25 @@ describe('EditCreationFormular', () => {
)
})
it('emits update-user-data', () => {
expect(wrapper.emitted('update-user-data')).toBeTruthy()
expect(wrapper.emitted('update-user-data')).toEqual([
[
{
id: 0,
email: 'bob@baumeister.de',
},
[0, 0, 0],
],
])
})
it('toast success message', () => {
expect(toastedSuccessMock).toBeCalledWith(
'Offene schöpfung (90 GDD) für bob@baumeister.de wurde geändert, liegt zur Bestätigung bereit',
)
})
describe('sendForm with error', () => {
beforeEach(async () => {
jest.clearAllMocks()
@ -163,8 +188,8 @@ describe('EditCreationFormular', () => {
variables: {
amount: 90,
creationDate: 'YYYY-MM-01',
email: undefined,
id: undefined,
email: 'bob@baumeister.de',
id: 0,
memo: 'Test create coins',
moderator: 0,
},
@ -219,8 +244,8 @@ describe('EditCreationFormular', () => {
variables: {
amount: 90,
creationDate: 'YYYY-MM-DD',
email: undefined,
id: undefined,
email: 'bob@baumeister.de',
id: 0,
memo: 'Test create coins',
moderator: 0,
},