Skip to content

Commit

Permalink
Test error case in sign in
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogge committed Mar 13, 2024
1 parent 71018db commit 8fd81b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 92 deletions.
84 changes: 0 additions & 84 deletions presenter/src/components/menu/#HeaderMenu.test.ts#

This file was deleted.

32 changes: 24 additions & 8 deletions presenter/src/components/menu/HeaderMenu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,33 @@ describe('HeaderMenu', () => {
describe('sign in button', () => {
const authServiceSpy = vi.spyOn(authService, 'signIn')

beforeEach(async () => {
vi.clearAllMocks()
await wrapper.find('button.sign-in').trigger('click')
describe('without error', () => {
beforeEach(async () => {
vi.clearAllMocks()
await wrapper.find('button.sign-in').trigger('click')
})

it('calls sign in from auth service', () => {
expect(authServiceSpy).toBeCalled()
})

it('navigates to /', () => {
expect(navigate).toBeCalledWith('/')
})
})

it('calls sign in from auth service', () => {
expect(authServiceSpy).toBeCalled()
})
describe('with error', () => {
const consoleSpy = vi.spyOn(global.console, 'log')

beforeEach(async () => {
vi.clearAllMocks()
authServiceSpy.mockRejectedValue('Ouch!')
await wrapper.find('button.sign-in').trigger('click')
})

it('navigates to /', () => {
expect(navigate).toBeCalledWith('/')
it('logs the error to console', () => {
expect(consoleSpy).toBeCalledWith('auth error', 'Ouch!')
})
})
})

Expand Down

0 comments on commit 8fd81b6

Please sign in to comment.