diff --git a/src/mixins/base-mixin.spec.js b/src/mixins/base-mixin.spec.js new file mode 100644 index 00000000..1d9fa569 --- /dev/null +++ b/src/mixins/base-mixin.spec.js @@ -0,0 +1,27 @@ +import baseMixin from "@/mixins/base-mixin" +import { shallowMount, mount } from "@vue/test-utils"; + + +describe("base-mixin", () => { + + it("should set and get cms content", () => { + const expected = "test"; + const wrapper = shallowMount(baseMixin, { + propsData: { + cmsContentByWidget: {} + } + }) + const cmsContent = { testWidget: { fieldName: expected }}; + + wrapper.componentVM.setCmsContent(cmsContent); + const actual = wrapper.componentVM.getCmsContent("testWidget", "fieldName"); + expect(actual).toEqual(expected); + }); + + it("should return formatted class name for cmswidget", () => { + + const localThis = { cmsWidgetName: "testWidget" } + expect(baseMixin.computed.cssClassNameForCmsWidget.call(localThis)).toBe("widget-name-testWidget") + + }); +}); \ No newline at end of file diff --git a/src/router/router.spec.js b/src/router/router.spec.js new file mode 100644 index 00000000..8c15c36c --- /dev/null +++ b/src/router/router.spec.js @@ -0,0 +1,44 @@ +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'; + +const originalLocation = global.location + +describe("Router", () => { + + beforeAll(() => { + const vueApp = createApp(App); + const pinia = createPinia(); + vueApp.use(pinia); + }) + + it("Should change the location when navigating to external site", () => { + delete global.location + global.location = { assign: jest.fn() } + + let scenario = navigationScenarios.CLICKED_TEST; + let currentRoute = { query: { issPage: issPageValues.WELCOME_PAGE }}; + + router.navigate(scenario, currentRoute); + + expect(global.location.assign).toHaveBeenCalledTimes(1) + + global.location = originalLocation; + }); + + it("Should push next view when navigating locally", () => { + let scenario = navigationScenarios.CLICKED_FORWARD; + let 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_YEAR) + + }); + +}); \ No newline at end of file