diff --git a/src/common-components/funnel-header/funnel-header.vue b/src/common-components/funnel-header/funnel-header.vue
index 7bd56904b..853363ec8 100644
--- a/src/common-components/funnel-header/funnel-header.vue
+++ b/src/common-components/funnel-header/funnel-header.vue
@@ -2,7 +2,7 @@
-
+
diff --git a/src/helpers/event-bus/event-bus.spec.js b/src/helpers/event-bus/event-bus.spec.js
new file mode 100644
index 000000000..d20c11044
--- /dev/null
+++ b/src/helpers/event-bus/event-bus.spec.js
@@ -0,0 +1,50 @@
+import { globalEvents, globalEventTypes } from "@/constants/events";
+import eventBus from "@/helpers/event-bus/event-bus";
+import store from "@/store";
+
+describe("event-bus.js", () => {
+
+ let event = {
+ isDismissible: true,
+ messageCopy: 'You can get a quote by starting on this page.',
+ messageHeadline: 'We\'re sorry, something went wrong.',
+ type: globalEventTypes.Danger
+ };
+
+ it("Puts item on bus and then take it off", () => {
+
+ // Arrange / Act
+ eventBus.addEventToBus(
+ globalEvents.Categories.GLOBAL_ALERT,
+ globalEvents.SubCategories.PAGE_NOT_FOUND,
+ event
+ );
+
+
+ // Assert
+ expect(store.getters.eventBusItem(globalEvents.Categories.GLOBAL_ALERT, globalEvents.SubCategories.PAGE_NOT_FOUND)).toEqual(event);
+
+ expect(store.state.applicationUser.eventBus.length).toEqual(1);
+
+ // Arrange / Act
+ const eventValue = eventBus.readAndPopEventFromBus(globalEvents.Categories.GLOBAL_ALERT, globalEvents.SubCategories.PAGE_NOT_FOUND);
+
+ // Assert
+ expect(eventValue).toEqual(event);
+
+ expect(store.state.applicationUser.eventBus.length).toEqual(0);
+ });
+
+ it("Reads event from bus, should have event value.", () => {
+ // Arrange / Act
+ eventBus.addEventToBus(
+ globalEvents.Categories.GLOBAL_ALERT,
+ globalEvents.SubCategories.PAGE_NOT_FOUND,
+ event
+ );
+
+ // Assert
+ expect(eventBus.readEventFromBus(globalEvents.Categories.GLOBAL_ALERT, globalEvents.SubCategories.PAGE_NOT_FOUND)).toEqual(event);
+
+ });
+});
\ No newline at end of file
diff --git a/src/store/index.js b/src/store/index.js
index f0fdb8bcd..f3937726a 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -3,6 +3,7 @@ import { endpoints } from "@/constants/endpoints.js";
import { storeMutations } from "@/constants/store-mutations"
import createPersistedState from "vuex-persistedstate";
import globalMethods from "@/global-methods";
+import eventBus from "../helpers/event-bus/event-bus";
export default createStore({
plugins: [createPersistedState()],
@@ -85,7 +86,7 @@ export default createStore({
// If the item exists, remove it.
if (itemIndex > -1) {
- state.applicationUser.eventBus.splice(itemIndex, 1);
+ state.applicationUser.eventBus.splice(itemIndex, 1);
}
}
},
diff --git a/src/store/store.spec.js b/src/store/store.spec.js
index 68de66b5e..0702f625d 100644
--- a/src/store/store.spec.js
+++ b/src/store/store.spec.js
@@ -253,10 +253,51 @@ describe("Mutations", () => {
expect(store.state.order.vehicle.carId).toBe("123abc");
expect(store.state.order.vehicle.category).toBe("car");
});
+
+ it("Should add event onto bus and update state", () => {
+ // Arrange
+ const event = {category: 'TestCategoryOne', subCategory: 'TestSubCategoryOne', eventValue: 'TestEventValueOne'};
+
+ // Act
+ store.commit("addEventToBus", event);
+
+ //Assert
+ expect(store.state.applicationUser.eventBus[0].category).toBe('TestCategoryOne');
+ expect(store.state.applicationUser.eventBus[0].subCategory).toBe('TestSubCategoryOne');
+ expect(store.state.applicationUser.eventBus[0].eventValue).toBe('TestEventValueOne');
+ });
});
describe("Getters", () => {
- const vehicle = store.getters.vehicle;
- expect(typeof vehicle).toBe('object');
+ it("Should validate vehicle getter", () => {
+ // Arrange
+ const vehicle = store.getters.vehicle;
+
+ // Assert
+ expect(typeof vehicle).toBe('object');
+ });
+
+ it("Should get item from bus via getter", () => {
+ // Arrange
+ const event = {category: 'TestCategoryOne', subCategory: 'TestSubCategoryOne', eventValue: 'TestEventValueOne'};
+
+ // Act
+ store.commit("addEventToBus", event)
+
+ // Assert
+ const returnedEventValue = store.getters.eventBusItem(event.category, event.subCategory);
+ expect(returnedEventValue).toBe('TestEventValueOne');
+ });
+
+ it("Should get eventbus from getter, should have length > 0", () => {
+ // Arrange
+ const event = {category: 'TestCategoryOne', subCategory: 'TestSubCategoryOne', eventValue: 'TestEventValueOne'};
+
+ // Act
+ store.commit("addEventToBus", event);
+
+ //Assert
+ expect(store.getters.eventBus.length).toBeGreaterThan(0);
+ });
});