mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
60 lines
1.1 KiB
JavaScript
60 lines
1.1 KiB
JavaScript
import { mount } from '@vue/test-utils'
|
|
import UserSearch from './UserSearch.vue'
|
|
|
|
const localVue = global.localVue
|
|
|
|
const apolloQueryMock = jest.fn().mockResolvedValue({
|
|
data: {
|
|
searchUsers: [
|
|
{
|
|
firstName: 'Bibi',
|
|
lastName: 'Bloxberg',
|
|
email: 'bibi@bloxberg.de',
|
|
creation: [200, 400, 600],
|
|
},
|
|
],
|
|
},
|
|
})
|
|
|
|
const toastErrorMock = jest.fn()
|
|
|
|
const mocks = {
|
|
$apollo: {
|
|
query: apolloQueryMock,
|
|
},
|
|
$toasted: {
|
|
error: toastErrorMock,
|
|
},
|
|
}
|
|
|
|
describe('UserSearch', () => {
|
|
let wrapper
|
|
|
|
const Wrapper = () => {
|
|
return mount(UserSearch, { localVue, mocks })
|
|
}
|
|
|
|
describe('mount', () => {
|
|
beforeEach(() => {
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('has a DIV element with the class.user-search', () => {
|
|
expect(wrapper.find('div.user-search').exists()).toBeTruthy()
|
|
})
|
|
|
|
describe('apollo returns error', () => {
|
|
beforeEach(() => {
|
|
apolloQueryMock.mockRejectedValue({
|
|
message: 'Ouch',
|
|
})
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('toasts an error message', () => {
|
|
expect(toastErrorMock).toBeCalledWith('Ouch')
|
|
})
|
|
})
|
|
})
|
|
})
|