fix router guards

This commit is contained in:
Andreani Jean
2023-07-04 21:27:23 +02:00
parent 6a75b53245
commit f9d385f3d9
4 changed files with 20 additions and 22 deletions

View File

@@ -44,16 +44,23 @@ describe('Template', () => {
}
}
})
expect(wrapper.html()).contains('path="api/auth/login')
expect(wrapper.html()).contains('api/auth/login')
})
})
describe('When the user is logged', () => {
it('should render the component with good wording keys', async () => {
Object.defineProperty(document, 'cookie', {
value: 'user_id=abc123'
})
vi.mock('vue3-cookies', () => ({
useCookies: vi.fn(() => ({
cookies: {
get: vi.fn(() => 'abc123') // Mock the cookies.get method
}
}))
}))
vi.resetModules()
import.meta.env.VITE_API_URL = 'api-url/'
const computed = {
isLogged: () => true
}
const wrapper = shallowMount(Header, {
props: {
authEnabled: true,
@@ -64,8 +71,10 @@ describe('Template', () => {
mocks: {
$t: (msg) => msg
}
}
},
computed
})
console.log(wrapper.html())
expect(wrapper.html()).contains('general.header.contribute_text')
expect(wrapper.html()).contains('general.header.my_information_text')
expect(wrapper.html()).contains('general.header.logout_text')

View File

@@ -49,7 +49,6 @@ describe('Template', () => {
expect(axios.get).toHaveBeenCalledWith('api/users/me/tokens')
expect(wrapper.vm.userTokens).toEqual(mockResponseTokens)
console.log('HTML', wrapper.html())
expect(wrapper.html()).contains('•••••••••••••••••••••••••••••••')
expect(wrapper.html()).contains('icon="bi bi-eye"')
expect(wrapper.html()).contains('look="button--rounded"')