From 1557c76bc5213ede3d3b14ba8ccdb15a68dcd7d4 Mon Sep 17 00:00:00 2001 From: Jeremy Zimmerman Date: Wed, 16 Nov 2022 15:56:13 -0500 Subject: [PATCH] Modified experiment unit tests. --- src/mixins/analytics-mixin.spec.js | 54 ++++++------------------------ 1 file changed, 10 insertions(+), 44 deletions(-) diff --git a/src/mixins/analytics-mixin.spec.js b/src/mixins/analytics-mixin.spec.js index 42f33d88..2f2faeac 100644 --- a/src/mixins/analytics-mixin.spec.js +++ b/src/mixins/analytics-mixin.spec.js @@ -112,10 +112,12 @@ describe("analyticsMixin.js", () => { // Assert expect(expectedDataLayer).toEqual(expect.arrayContaining(window.dataLayer)); }); -/* + test("Experiments, should push to dataLayer with default Google Custom Dimension Index", () => { // Arrange - window.dataLayer = []; + const store = useMainStore(); + + window.dataLayer = []; const mockExperimentData = [ { @@ -125,26 +127,7 @@ describe("analyticsMixin.js", () => { }, ]; - // Mock store - jest.mock( - "@/store", - () => { - return {}; - }, - { virtual: true } - ); - - useMainStore.getters = { - applicationUserObj: { - experiments: [ - { - settings: {}, - variationName: "test", - universeName: "testUniverse", - }, - ], - }, - }; + store.applicationUserObj.experiments = mockExperimentData; // Act analyticsMixin.methods.pushExperimentsToDataLayer(mockExperimentData); @@ -163,7 +146,9 @@ describe("analyticsMixin.js", () => { test("Experiments, should push to dataLayer with custom Google Custom Dimension Index", () => { // Arrange - window.dataLayer = []; + const store = useMainStore(); + + window.dataLayer = []; const mockExperimentData = [ { @@ -173,26 +158,7 @@ describe("analyticsMixin.js", () => { }, ]; - // Mock store - jest.mock( - "@/store", - () => { - return {}; - }, - { virtual: true } - ); - - useMainStore.getters = { - applicationUserObj: { - experiments: [ - { - settings: { "Google Custom Dimension Index": "5" }, - variationName: "test", - universeName: "testUniverse", - }, - ], - }, - }; + store.applicationUserObj.experiments = mockExperimentData; // Act analyticsMixin.methods.pushExperimentsToDataLayer(mockExperimentData); @@ -208,7 +174,7 @@ describe("analyticsMixin.js", () => { }, ]); }); -*/ + test("Obj is not null after action prepended", () => { //Arrange const obj = { baseMethodName: "testMethodName", data: "testData" };