mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
add tests for usersearch
This commit is contained in:
parent
6c31480e31
commit
051e7212f2
@ -34,7 +34,7 @@ describe('Sidebar', () => {
|
||||
|
||||
describe('the genaral section', () => {
|
||||
it('has six nav-items', () => {
|
||||
expect(wrapper.findAll('ul').at(0).findAll('.nav-item')).toHaveLength(6)
|
||||
expect(wrapper.findAll('ul').at(0).findAll('.nav-item')).toHaveLength(7)
|
||||
})
|
||||
|
||||
it('has nav-item "navigation.overview" in navbar', () => {
|
||||
@ -60,6 +60,10 @@ describe('Sidebar', () => {
|
||||
it('has nav-item "navigation.info" in navbar', () => {
|
||||
expect(wrapper.findAll('.nav-item').at(5).text()).toContain('navigation.info')
|
||||
})
|
||||
|
||||
it('has nav-item "usersearch" in navbar', () => {
|
||||
expect(wrapper.findAll('.nav-item').at(6).text()).toContain('navigation.usersearch')
|
||||
})
|
||||
})
|
||||
|
||||
describe('the specific section', () => {
|
||||
|
||||
80
frontend/src/pages/UserSearch.spec.js
Normal file
80
frontend/src/pages/UserSearch.spec.js
Normal file
@ -0,0 +1,80 @@
|
||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
||||
import UserSearch from './UserSearch'
|
||||
import { toastErrorSpy } from '../../test/testSetup'
|
||||
import { authenticateGmsUserSearch } from '@/graphql/queries'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
window.scrollTo = jest.fn()
|
||||
|
||||
const stubs = {
|
||||
RouterLink: RouterLinkStub,
|
||||
}
|
||||
|
||||
const apolloQueryMock = jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
data: {
|
||||
authenticateGmsUserSearch: {
|
||||
gmsUri: 'http://localhost:8080/playground?not initialized',
|
||||
},
|
||||
},
|
||||
})
|
||||
.mockResolvedValue('default')
|
||||
|
||||
|
||||
describe('UserSearch', () => {
|
||||
let wrapper
|
||||
|
||||
const mocks = {
|
||||
$t: jest.fn((t) => t),
|
||||
$n: jest.fn(),
|
||||
$i18n: {
|
||||
locale: 'en',
|
||||
},
|
||||
$apollo: {
|
||||
query: apolloQueryMock,
|
||||
},
|
||||
}
|
||||
|
||||
const Wrapper = () => {
|
||||
return mount(UserSearch, {
|
||||
localVue,
|
||||
mocks,
|
||||
})
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('renders the usersearch page', () => {
|
||||
expect(wrapper.find('div.usersearch').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('calls authenticateGmsUserSearch', () => {
|
||||
expect(apolloQueryMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
query: authenticateGmsUserSearch,
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
describe('error apolloQueryMock', () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
apolloQueryMock.mockRejectedValue({
|
||||
message: 'uups',
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith(
|
||||
'authenticateGmsUserSearch failed!',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -49,8 +49,8 @@ describe('router', () => {
|
||||
expect(routes.find((r) => r.path === '/').redirect()).toEqual({ path: '/login' })
|
||||
})
|
||||
|
||||
it('has 19 routes defined', () => {
|
||||
expect(routes).toHaveLength(19)
|
||||
it('has 20 routes defined', () => {
|
||||
expect(routes).toHaveLength(20)
|
||||
})
|
||||
|
||||
describe('overview', () => {
|
||||
@ -142,6 +142,17 @@ describe('router', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('usersearch', () => {
|
||||
it('requires authorization', () => {
|
||||
expect(routes.find((r) => r.path === '/usersearch').meta.requiresAuth).toBeTruthy()
|
||||
})
|
||||
|
||||
it('loads the "UserSearch" page', async () => {
|
||||
const component = await routes.find((r) => r.path === '/usersearch').component()
|
||||
expect(component.default.name).toBe('UserSearch')
|
||||
})
|
||||
})
|
||||
|
||||
describe('gdt', () => {
|
||||
it('requires authorization', () => {
|
||||
expect(routes.find((r) => r.path === '/gdt').meta.requiresAuth).toBeTruthy()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user