Everything seems to be working now, need to update tests
This commit is contained in:
parent
652eed2585
commit
4475508db5
5 changed files with 37 additions and 24 deletions
|
|
@ -1,25 +1,25 @@
|
||||||
import siteHeader from "@/common-components/site-header/site-header";
|
import siteHeader from "@/common-components/site-header/site-header";
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
|
||||||
describe("site-header", () => {
|
describe("site-header", () => {
|
||||||
|
|
||||||
test("renders the logo image", () => {
|
test("renders the logo image", () => {
|
||||||
const wrapper = shallowMount(siteHeader, {
|
const wrapper = setupMocks({mountOptionsMockData: {}});
|
||||||
setProps: {
|
|
||||||
cmsWidgetName: "header",
|
|
||||||
},
|
|
||||||
mixins: [mockMixin]
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.find("img")).toBeTruthy();
|
expect(wrapper.find("img")).toBeTruthy();
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockMixin = {
|
function setupMocks({
|
||||||
methods: {
|
mountOptionsMockData = {},
|
||||||
getCmsContent: jest.fn()
|
}) {
|
||||||
}
|
|
||||||
|
const mountOptions = getMountOptions(mountOptionsMockData);
|
||||||
|
const wrapper = shallowMount(siteHeader, mountOptions);
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { useMainStore } from '@/store';
|
||||||
export default {
|
export default {
|
||||||
// Adds event to the bus given its category, subcategory, and eventValue;
|
// Adds event to the bus given its category, subcategory, and eventValue;
|
||||||
addEventToBus(category, subCategory, eventValue) {
|
addEventToBus(category, subCategory, eventValue) {
|
||||||
|
|
||||||
useMainStore().addEventToBus( {
|
useMainStore().addEventToBus( {
|
||||||
category: category,
|
category: category,
|
||||||
subCategory: subCategory,
|
subCategory: subCategory,
|
||||||
|
|
|
||||||
|
|
@ -117,13 +117,13 @@ function setupMocks({
|
||||||
//Mock api responses
|
//Mock api responses
|
||||||
const apiResponses = {
|
const apiResponses = {
|
||||||
cmsContent: {
|
cmsContent: {
|
||||||
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
|
SiteSubHeaderWidget: pageHeaderWidgetHeaderText,
|
||||||
VehicleModelQuestion: buttonQuestionContent,
|
VehicleModelQuestion: buttonQuestionContent,
|
||||||
VehicleBannerWidget: {
|
VehicleBannerWidget: {
|
||||||
GenericVehicleImage:
|
GenericVehicleImage:
|
||||||
"https://digitalisscms.dev.safelite.io/images/default-source/default-album/blurred-image.jpg",
|
"https://digitalisscms.dev.safelite.io/images/default-source/default-album/blurred-image.jpg",
|
||||||
},
|
},
|
||||||
FunnelHeaderWidget: {
|
SiteHeaderWidget: {
|
||||||
LogoImage:
|
LogoImage:
|
||||||
"https://digitalisscms.dev.safelite.io/images/default-source/default-album/logos/insuranceLogo.jpg",
|
"https://digitalisscms.dev.safelite.io/images/default-source/default-album/logos/insuranceLogo.jpg",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader";
|
||||||
import {issPageValues} from '@/router/router-constants/issPage-values';
|
import {issPageValues} from '@/router/router-constants/issPage-values';
|
||||||
import { routingTable } from "@/router/router-constants/routing-table";
|
import { routingTable } from "@/router/router-constants/routing-table";
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
import eventBus from "@/helpers/event-bus/event-bus";
|
||||||
|
import { globalEvents, globalEventTypes } from "@/constants/events";
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
|
@ -141,13 +143,25 @@ function getNavigationMap (scenario, currentRoute) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function GoToStartOn404(next) {
|
function GoToStartOn404(next) {
|
||||||
const errorPageName = issPageValues.ERROR_404;
|
const errorPageName = issPageValues.VEHICLE_YEAR;
|
||||||
router.addRoute({
|
router.addRoute({
|
||||||
path: "/",
|
path: "/",
|
||||||
name: errorPageName,
|
name: errorPageName,
|
||||||
component: lazyLoadComponent(errorPageName),
|
component: lazyLoadComponent(errorPageName),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Put item on the bus
|
||||||
|
eventBus.addEventToBus(
|
||||||
|
globalEvents.Categories.GLOBAL_ALERT,
|
||||||
|
globalEvents.SubCategories.PAGE_NOT_FOUND,
|
||||||
|
{
|
||||||
|
isDismissible: true,
|
||||||
|
messageCopy: "You can get a quote by starting on this page.",
|
||||||
|
messageHeadline: "We're sorry, something went wrong.",
|
||||||
|
type: globalEventTypes.Danger,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
next({
|
next({
|
||||||
name: errorPageName,
|
name: errorPageName,
|
||||||
query: {issPage: errorPageName },
|
query: {issPage: errorPageName },
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,10 @@ export const useMainStore = defineStore({
|
||||||
id: storeId,
|
id: storeId,
|
||||||
state: () => state,
|
state: () => state,
|
||||||
getters: {
|
getters: {
|
||||||
eventBusItem: (state) => (eventCategory, eventSubCategory) => {
|
eventBusItem: (state) => ( eventCategory, eventSubCategory) => {
|
||||||
|
|
||||||
const matchedEvent = state.applicationUser.eventBus.find(
|
const matchedEvent = state.applicationUser.eventBus.find(
|
||||||
({ category, subCategory }) =>
|
( { category, subCategory } ) =>
|
||||||
category === eventCategory && subCategory === eventSubCategory
|
category === eventCategory && subCategory === eventSubCategory
|
||||||
);
|
);
|
||||||
return matchedEvent?.eventValue;
|
return matchedEvent?.eventValue;
|
||||||
|
|
@ -146,19 +146,19 @@ export const useMainStore = defineStore({
|
||||||
this.order.vehicle.style = style;
|
this.order.vehicle.style = style;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addEventToBus(state, event) {
|
addEventToBus (event) {
|
||||||
state.applicationUser.eventBus.push(event);
|
this.applicationUser.eventBus.push(event);
|
||||||
},
|
},
|
||||||
removeEventFromBus(state, eventData) {
|
removeEventFromBus (eventData) {
|
||||||
const matchedEvent = state.applicationUser.eventBus.find(
|
const matchedEvent = this.applicationUser.eventBus.find(
|
||||||
({ category, subCategory }) =>
|
( {category, subCategory } ) =>
|
||||||
category === eventData.category && subCategory === eventData.subCategory
|
category === eventData.category && subCategory === eventData.subCategory
|
||||||
);
|
);
|
||||||
const itemIndex = state.applicationUser.eventBus.indexOf(matchedEvent);
|
const itemIndex = this.applicationUser.eventBus.indexOf(matchedEvent);
|
||||||
|
|
||||||
// If the item exists, remove it.
|
// If the item exists, remove it.
|
||||||
if (itemIndex > -1) {
|
if (itemIndex > -1) {
|
||||||
state.applicationUser.eventBus.splice(itemIndex, 1);
|
this.applicationUser.eventBus.splice(itemIndex, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue