53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import router from '@/router/';
|
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
|
import issPageValues from '@/router/router-constants/issPage-values';
|
|
import { createApp } from 'vue';
|
|
import { createPinia } from 'pinia';
|
|
import App from '@/App.vue';
|
|
import bailoutMessage from '@/constants/bailoutMessage';
|
|
import { useMainStore } from '@/store';
|
|
|
|
describe('Router', () => {
|
|
beforeAll(() => {
|
|
const vueApp = createApp(App);
|
|
const pinia = createPinia();
|
|
vueApp.use(pinia);
|
|
});
|
|
|
|
it('Should push next view when navigating locally', () => {
|
|
const scenario = navigationScenarios.CLICKED_FORWARD;
|
|
const currentRoute = { query: { issPage: issPageValues.WELCOME_PAGE } };
|
|
|
|
router.push = jest.fn();
|
|
|
|
router.navigate(scenario, currentRoute);
|
|
expect(router.push.mock.calls[0][0].query.issPage).toBe(issPageValues.VEHICLE_SELECTION);
|
|
});
|
|
|
|
it('Should set state as expected', () => {
|
|
// Arrange
|
|
const scenario = navigationScenarios.CLICKED_FORWARD;
|
|
const currentRoute = { query: { issPage: issPageValues.WELCOME_PAGE } };
|
|
const parameters = {saveSync: true};
|
|
|
|
router.push = jest.fn();
|
|
|
|
// Act
|
|
router.navigate(scenario, currentRoute, {}, parameters);
|
|
|
|
// Assert
|
|
expect(router.push.mock.calls[0][0].state).toBe(parameters);
|
|
});
|
|
|
|
it('Should set bailout and navigate to bailout page when calling navigateBailout', () => {
|
|
// Arrange
|
|
router.push = jest.fn();
|
|
|
|
// Act
|
|
router.navigateBailout(bailoutMessage.unknown({}));
|
|
|
|
// Assert
|
|
expect(router.push.mock.calls[0][0].query.issPage).toBe(issPageValues.BAILOUT_PAGE);
|
|
expect(useMainStore().isBailout).toBeTruthy();
|
|
});
|
|
});
|