Merge pull request #11 from Safelite/feature/Digital/SSR-67
Feature/digital/ssr 67
This commit is contained in:
commit
4071be721f
6 changed files with 128 additions and 5 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>
|
<script>
|
||||||
|
|
||||||
export default({
|
export default({
|
||||||
name: "nav-button",
|
name: "navButton",
|
||||||
props: {
|
props: {
|
||||||
text: String,
|
text: String,
|
||||||
scenario: String,
|
scenario: String,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
import axios from 'axios';
|
|
||||||
import '@/global-methods.js';
|
|
||||||
|
|
||||||
test.todo("Need to add some tests here");
|
|
||||||
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