more tests for all nav-items

This commit is contained in:
ogerly 2022-11-01 13:44:09 +01:00
parent f0e6793074
commit c7c25f2077

View File

@ -7,6 +7,10 @@ const apolloMutateMock = jest.fn()
const storeDispatchMock = jest.fn()
const routerPushMock = jest.fn()
const stubs = {
RouterLink: true,
}
const mocks = {
$t: jest.fn((t) => t),
$apollo: {
@ -28,7 +32,7 @@ describe('NavBar', () => {
let wrapper
const Wrapper = () => {
return mount(NavBar, { mocks, localVue })
return mount(NavBar, { mocks, localVue, stubs })
}
describe('mount', () => {
@ -41,13 +45,35 @@ describe('NavBar', () => {
})
})
describe('Navbar Menu', () => {
it('has a link to overview', () => {
expect(wrapper.findAll('.nav-item').at(0).find('a').attributes('href')).toBe('/')
})
it('has a link to /user', () => {
expect(wrapper.findAll('.nav-item').at(1).find('a').attributes('href')).toBe('/user')
})
it('has a link to /creation', () => {
expect(wrapper.findAll('.nav-item').at(2).find('a').attributes('href')).toBe('/creation')
})
it('has a link to /creation-confirm', () => {
expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe(
'/creation-confirm',
)
})
it('has a link to /contribution-link', () => {
expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe(
'/contribution-link',
)
})
})
describe('wallet', () => {
const assignLocationSpy = jest.fn()
beforeEach(async () => {
await wrapper.findAll('a').at(6).trigger('click')
await wrapper.findAll('.nav-item').at(5).find('a').trigger('click')
})
it.skip('changes widnow location to wallet', () => {
it.skip('changes window location to wallet', () => {
expect(assignLocationSpy).toBeCalledWith('valid-token')
})
@ -63,7 +89,7 @@ describe('NavBar', () => {
window.location = {
assign: windowLocationMock,
}
await wrapper.findAll('a').at(7).trigger('click')
await wrapper.findAll('.nav-item').at(6).find('a').trigger('click')
})
it('redirects to /logout', () => {