diff --git a/src/mixins/analytics-mixin.spec.js b/src/mixins/analytics-mixin.spec.js index 8f7cfceaa..7e04215af 100644 --- a/src/mixins/analytics-mixin.spec.js +++ b/src/mixins/analytics-mixin.spec.js @@ -1,5 +1,5 @@ import analyticsMixin from "@/mixins/analytics-mixin"; -import { setupMocksForJsFiles, setupCookies } from "@/helpers/unit-test-helper.js"; +import { setupMocksForJsFiles, setupCookies, setupCrypto } from "@/helpers/unit-test-helper.js"; import { storeActions } from "@/constants/store-actions"; import { analyticsPageEvents, @@ -11,19 +11,12 @@ import { } from "@/constants/analytics"; import store from "@/store"; -// Mock only the regenerate functions; window.crypto is not available in testing. -jest.mock("@/helpers/heritage-integration/cookie-helper", () => { - const originalModule = jest.requireActual("@/helpers/heritage-integration/cookie-helper"); - - return { - __esModule: true, - ...originalModule, - regenerateDeviceId: jest.fn(), - regenerateUserId: jest.fn(), - }; -}); describe("analyticsMixin.js", () => { + beforeEach(() => { + setupCrypto(); + }); + test("logPageView: calls dispatch with type and payload", async () => { const type = ""; const payload = {};