Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove logging test #211

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions src/tracking.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @flow */
/* eslint-disable promise/no-native, no-restricted-globals, compat/compat */

import { describe, it, vi, expect } from "vitest";

import { makeMockScriptElement } from "../test/helpers";
Expand All @@ -9,17 +9,12 @@ import { getSDKInitTime, setupLogger } from "./tracking";
const clientId = "foobar123";
const mockScriptSrc = `https://test.paypal.com/sdk/js?client-id=${clientId}`;

let metricCounterSpy;
let windowReadyPromiseResolver;
vi.mock("./logger", async () => {
const actual = await vi.importActual("./logger");
return {
...actual,
getLogger: vi.fn(() => {
const logger = actual.getLogger();
metricCounterSpy = vi
.spyOn(logger, "metricCounter")
.mockImplementation(() => {}); // eslint-disable-line no-empty-function
return logger;
}),
};
Expand All @@ -32,11 +27,6 @@ vi.mock("@krakenjs/belter/src", async () => {
getCurrentScript: vi.fn(() => {
return makeMockScriptElement(mockScriptSrc);
}),
waitForWindowReady: vi.fn(() => {
return new Promise((resolve) => {
windowReadyPromiseResolver = resolve;
});
}),
};
});

Expand All @@ -50,25 +40,4 @@ describe(`tracking cases`, () => {
setupLogger();
expect(getSDKInitTime()).toEqual(expect.any(Number));
});

it("setupLogger should setup logger with IEIntranet enabled", () => {
window.document.documentMode = true;
setupLogger();
});

it("should call metric counter on window load", async () => {
windowReadyPromiseResolver();
await new Promise((resolve) => setTimeout(resolve)); // Flush promises

expect(metricCounterSpy).toHaveBeenCalledWith(
expect.objectContaining({
namespace: "sdk_client.init.count",
dimensions: expect.objectContaining({
isPayPalDomain: "false",
}),
})
);
});
});

/* eslint-enable promise/no-native, no-restricted-globals, compat/compat */
Loading