Fixe error toast test.

This commit is contained in:
elweyn 2021-10-06 08:45:20 +02:00
parent ddb9d457d2
commit 6c8f5c5772
2 changed files with 33 additions and 1 deletions

View File

@ -91,7 +91,7 @@ describe('Login', () => {
apolloQueryMock.mockRejectedValue({
message: 'Failed to get communities',
})
wrapper = new Wrapper()
wrapper = Wrapper()
})
it('toasts an error message', () => {

View File

@ -9,6 +9,19 @@ const spinnerMock = jest.fn(() => {
hide: spinnerHideMock,
}
})
const apolloQueryMock = jest.fn().mockResolvedValue({
data: {
communities: [
{
name: 'test1',
description: 'description 1',
url: 'http://test.test/vue',
registerUrl: 'http://localhost/vue/register-community',
},
],
},
})
const toasterMock = jest.fn()
describe('RegisterSelectCommunity', () => {
let wrapper
@ -28,9 +41,15 @@ describe('RegisterSelectCommunity', () => {
},
},
},
$apollo: {
query: apolloQueryMock,
},
$loading: {
show: spinnerMock,
},
$toasted: {
error: toasterMock,
},
}
const Wrapper = () => {
@ -45,5 +64,18 @@ describe('RegisterSelectCommunity', () => {
it('renders the Div Element "#register-select-community"', () => {
expect(wrapper.find('div#register-select-community').exists()).toBeTruthy()
})
describe('calls the apollo query', () => {
beforeEach(() => {
apolloQueryMock.mockRejectedValue({
message: 'Wrong thing',
})
wrapper = Wrapper()
})
it('toast an error', () => {
expect(toasterMock).toBeCalledWith('Wrong thing')
})
})
})
})