-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
77 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,62 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { describe, it, expect } from 'vitest' | ||
import { navigate } from 'vike/client/router' | ||
import { describe, it, expect, vi, beforeEach } from 'vitest' | ||
import { Component, h } from 'vue' | ||
import { VApp } from 'vuetify/components' | ||
|
||
import { authService } from '#tests/mock.authService' | ||
|
||
import SilentRefreshPage from './+Page.vue' | ||
import { title } from './+title' | ||
|
||
vi.mock('vike/client/router') | ||
vi.mocked(navigate).mockResolvedValue() | ||
|
||
describe('SilentRefreshPage', () => { | ||
const wrapper = mount(VApp, { | ||
slots: { | ||
default: h(SilentRefreshPage as Component), | ||
}, | ||
}) | ||
const authServiceSpy = vi.spyOn(authService, 'renewToken') | ||
|
||
const Wrapper = () => { | ||
return mount(VApp, { | ||
slots: { | ||
default: h(SilentRefreshPage as Component), | ||
}, | ||
}) | ||
} | ||
|
||
let wrapper: ReturnType<typeof Wrapper> | ||
|
||
describe('auth service with succes', () => { | ||
beforeEach(() => { | ||
wrapper = Wrapper() | ||
}) | ||
|
||
it('title returns correct title', () => { | ||
expect(title).toBe('DreamMall | Authentifizierung') | ||
it('title returns correct title', () => { | ||
expect(title).toBe('DreamMall | Authentifizierung') | ||
}) | ||
|
||
it('renders', () => { | ||
expect(wrapper.element).toMatchSnapshot() | ||
}) | ||
|
||
it('calls renew token of auth service', () => { | ||
expect(authServiceSpy).toBeCalled() | ||
}) | ||
|
||
it('navigatesto /', () => { | ||
expect(navigate).toBeCalledWith('/') | ||
}) | ||
}) | ||
|
||
it('renders', () => { | ||
expect(wrapper.element).toMatchSnapshot() | ||
describe('auth service throws', () => { | ||
const consoleSpy = vi.spyOn(global.console, 'log') | ||
|
||
beforeEach(() => { | ||
authServiceSpy.mockRejectedValue('Ouch!') | ||
wrapper = Wrapper() | ||
}) | ||
|
||
it('logs error to console', () => { | ||
expect(consoleSpy).toBeCalledWith('auth error', 'Ouch!') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters