Merge branch 'develop' into feature/Digital/SSR-65
This commit is contained in:
commit
90cac6bc46
5 changed files with 128 additions and 1 deletions
35
src/common-components/nav-button/nav-button.spec.js
Normal file
35
src/common-components/nav-button/nav-button.spec.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import navButton from "./nav-button"
|
||||
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
|
||||
describe('NavButton', () => {
|
||||
|
||||
it('should display input when type is button', () => {
|
||||
const wrapper = shallowMount(navButton, {
|
||||
propsData: {
|
||||
text: "Hello",
|
||||
scenario: "test",
|
||||
type: "button"
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.find('input').exists()).toBe(true);
|
||||
expect(wrapper.find('p').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('should display p element when type is text', () => {
|
||||
const wrapper = shallowMount(navButton, {
|
||||
propsData: {
|
||||
text: "Hello",
|
||||
scenario: "test",
|
||||
type: "text"
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.find('input').exists()).toBe(false);
|
||||
expect(wrapper.find('p').exists()).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
<script>
|
||||
|
||||
export default({
|
||||
name: "nav-button",
|
||||
name: "navButton",
|
||||
props: {
|
||||
text: String,
|
||||
scenario: String,
|
||||
|
|
|
|||
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)
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
21
src/store/store.spec.js
Normal file
21
src/store/store.spec.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { useMainStore } from "./"
|
||||
import { createApp } from 'vue';
|
||||
import { createPinia } from "pinia";
|
||||
import App from '@/App.vue';
|
||||
|
||||
describe("Store", () => {
|
||||
let store = null;
|
||||
|
||||
beforeAll(() => {
|
||||
const vueApp = createApp(App);
|
||||
const pinia = createPinia();
|
||||
vueApp.use(pinia);
|
||||
store = useMainStore();
|
||||
})
|
||||
|
||||
it("Should Store Vehicle Year", () => {
|
||||
let testYear = "2001";
|
||||
store.updateVehicleYear(testYear);
|
||||
expect(store.order.vehicle.year).toEqual(testYear);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue