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', () => { describe('with mass creation', () => {
beforeEach(async () => { beforeEach(async () => {
jest.clearAllMocks() 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', () => { describe('first radio button', () => {

View File

@ -16,6 +16,7 @@ const apolloMutateMock = jest.fn().mockResolvedValue({
const stateCommitMock = jest.fn() const stateCommitMock = jest.fn()
const toastedErrorMock = jest.fn() const toastedErrorMock = jest.fn()
const toastedSuccessMock = jest.fn()
const mocks = { const mocks = {
$moment: jest.fn(() => { $moment: jest.fn(() => {
@ -42,6 +43,7 @@ const mocks = {
}, },
$toasted: { $toasted: {
error: toastedErrorMock, error: toastedErrorMock,
success: toastedSuccessMock,
}, },
} }
@ -52,6 +54,10 @@ const propsData = {
amount: 100, amount: 100,
date: '2021-12-01', date: '2021-12-01',
}, },
item: {
id: 0,
email: 'bob@baumeister.de',
},
} }
describe('EditCreationFormular', () => { describe('EditCreationFormular', () => {
@ -108,8 +114,8 @@ describe('EditCreationFormular', () => {
variables: { variables: {
amount: 90, amount: 90,
creationDate: 'YYYY-MM-01', creationDate: 'YYYY-MM-01',
email: undefined, email: 'bob@baumeister.de',
id: undefined, id: 0,
memo: 'Test create coins', memo: 'Test create coins',
moderator: 0, 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', () => { describe('sendForm with error', () => {
beforeEach(async () => { beforeEach(async () => {
jest.clearAllMocks() jest.clearAllMocks()
@ -163,8 +188,8 @@ describe('EditCreationFormular', () => {
variables: { variables: {
amount: 90, amount: 90,
creationDate: 'YYYY-MM-01', creationDate: 'YYYY-MM-01',
email: undefined, email: 'bob@baumeister.de',
id: undefined, id: 0,
memo: 'Test create coins', memo: 'Test create coins',
moderator: 0, moderator: 0,
}, },
@ -219,8 +244,8 @@ describe('EditCreationFormular', () => {
variables: { variables: {
amount: 90, amount: 90,
creationDate: 'YYYY-MM-DD', creationDate: 'YYYY-MM-DD',
email: undefined, email: 'bob@baumeister.de',
id: undefined, id: 0,
memo: 'Test create coins', memo: 'Test create coins',
moderator: 0, moderator: 0,
}, },