Properly mock crypto module
This commit is contained in:
parent
67c9b1609b
commit
ef5a6a55e3
1 changed files with 5 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import analyticsMixin from "@/mixins/analytics-mixin";
|
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 { storeActions } from "@/constants/store-actions";
|
||||||
import {
|
import {
|
||||||
analyticsPageEvents,
|
analyticsPageEvents,
|
||||||
|
|
@ -11,19 +11,12 @@ import {
|
||||||
} from "@/constants/analytics";
|
} from "@/constants/analytics";
|
||||||
import store from "@/store";
|
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", () => {
|
describe("analyticsMixin.js", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setupCrypto();
|
||||||
|
});
|
||||||
|
|
||||||
test("logPageView: calls dispatch with type and payload", async () => {
|
test("logPageView: calls dispatch with type and payload", async () => {
|
||||||
const type = "";
|
const type = "";
|
||||||
const payload = {};
|
const payload = {};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue