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';

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);
    });
});
