added some additional tests
This commit is contained in:
parent
1db98e726a
commit
efc7a080b9
2 changed files with 71 additions and 0 deletions
27
src/mixins/base-mixin.spec.js
Normal file
27
src/mixins/base-mixin.spec.js
Normal file
|
|
@ -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")
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
44
src/router/router.spec.js
Normal file
44
src/router/router.spec.js
Normal file
|
|
@ -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)
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue