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 { shallowMount } from "@vue/test-utils";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
|
||||
describe("site-header", () => {
|
||||
|
||||
test("renders the logo image", () => {
|
||||
const wrapper = shallowMount(siteHeader, {
|
||||
setProps: {
|
||||
cmsWidgetName: "header",
|
||||
},
|
||||
mixins: [mockMixin]
|
||||
});
|
||||
const wrapper = setupMocks({mountOptionsMockData: {}});
|
||||
|
||||
|
||||
expect(wrapper.find("img")).toBeTruthy();
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn()
|
||||
}
|
||||
function setupMocks({
|
||||
mountOptionsMockData = {},
|
||||
}) {
|
||||
|
||||
const mountOptions = getMountOptions(mountOptionsMockData);
|
||||
const wrapper = shallowMount(siteHeader, mountOptions);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { useMainStore } from '@/store';
|
|||
export default {
|
||||
// Adds event to the bus given its category, subcategory, and eventValue;
|
||||
addEventToBus(category, subCategory, eventValue) {
|
||||
|
||||
useMainStore().addEventToBus( {
|
||||
category: category,
|
||||
subCategory: subCategory,
|
||||
|
|
|
|||
|
|
@ -117,13 +117,13 @@ function setupMocks({
|
|||
//Mock api responses
|
||||
const apiResponses = {
|
||||
cmsContent: {
|
||||
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
|
||||
SiteSubHeaderWidget: pageHeaderWidgetHeaderText,
|
||||
VehicleModelQuestion: buttonQuestionContent,
|
||||
VehicleBannerWidget: {
|
||||
GenericVehicleImage:
|
||||
"https://digitalisscms.dev.safelite.io/images/default-source/default-album/blurred-image.jpg",
|
||||
},
|
||||
FunnelHeaderWidget: {
|
||||
SiteHeaderWidget: {
|
||||
LogoImage:
|
||||
"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 { routingTable } from "@/router/router-constants/routing-table";
|
||||
import { useMainStore } from '@/store';
|
||||
import eventBus from "@/helpers/event-bus/event-bus";
|
||||
import { globalEvents, globalEventTypes } from "@/constants/events";
|
||||
|
||||
const routes = [
|
||||
{
|
||||
|
|
@ -141,13 +143,25 @@ function getNavigationMap (scenario, currentRoute) {
|
|||
};
|
||||
|
||||
function GoToStartOn404(next) {
|
||||
const errorPageName = issPageValues.ERROR_404;
|
||||
const errorPageName = issPageValues.VEHICLE_YEAR;
|
||||
router.addRoute({
|
||||
path: "/",
|
||||
name: 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({
|
||||
name: errorPageName,
|
||||
query: {issPage: errorPageName },
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ export const useMainStore = defineStore({
|
|||
id: storeId,
|
||||
state: () => state,
|
||||
getters: {
|
||||
eventBusItem: (state) => (eventCategory, eventSubCategory) => {
|
||||
eventBusItem: (state) => ( eventCategory, eventSubCategory) => {
|
||||
|
||||
const matchedEvent = state.applicationUser.eventBus.find(
|
||||
({ category, subCategory }) =>
|
||||
( { category, subCategory } ) =>
|
||||
category === eventCategory && subCategory === eventSubCategory
|
||||
);
|
||||
return matchedEvent?.eventValue;
|
||||
|
|
@ -146,19 +146,19 @@ export const useMainStore = defineStore({
|
|||
this.order.vehicle.style = style;
|
||||
}
|
||||
},
|
||||
addEventToBus(state, event) {
|
||||
state.applicationUser.eventBus.push(event);
|
||||
addEventToBus (event) {
|
||||
this.applicationUser.eventBus.push(event);
|
||||
},
|
||||
removeEventFromBus(state, eventData) {
|
||||
const matchedEvent = state.applicationUser.eventBus.find(
|
||||
({ category, subCategory }) =>
|
||||
removeEventFromBus (eventData) {
|
||||
const matchedEvent = this.applicationUser.eventBus.find(
|
||||
( {category, 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 (itemIndex > -1) {
|
||||
state.applicationUser.eventBus.splice(itemIndex, 1);
|
||||
this.applicationUser.eventBus.splice(itemIndex, 1);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue