Merge branch 'adminPendingCreationQueries' into adminEditPendingCreationQueries

This commit is contained in:
elweyn 2021-12-02 07:07:13 +01:00
commit a8919a0b08

View File

@ -3,6 +3,16 @@ import CreationFormular from './CreationFormular.vue'
const localVue = global.localVue
const apolloMock = jest.fn().mockResolvedValue({
data: {
verifyLogin: {
name: 'success',
id: 0,
},
},
})
const stateCommitMock = jest.fn()
const mocks = {
$moment: jest.fn(() => {
return {
@ -14,6 +24,12 @@ const mocks = {
}),
}
}),
$apollo: {
query: apolloMock,
},
$store: {
commit: stateCommitMock,
},
}
const propsData = {
@ -39,6 +55,23 @@ describe('CreationFormular', () => {
expect(wrapper.find('.component-creation-formular').exists()).toBeTruthy()
})
describe('server sends back moderator data', () => {
it('called store commit with mocked data', () => {
expect(stateCommitMock).toBeCalledWith('moderator', { name: 'success', id: 0 })
})
})
describe('server throws error for moderator data call', () => {
beforeEach(() => {
jest.clearAllMocks()
apolloMock.mockRejectedValue({ message: 'Ouch!' })
wrapper = Wrapper()
})
it('has called store commit with fake data', () => {
expect(stateCommitMock).toBeCalledWith('moderator', { id: 0, name: 'Test Moderator' })
})
})
describe('radio buttons to selcet month', () => {
it('has three radio buttons', () => {
expect(wrapper.findAll('input[type="radio"]').length).toBe(3)