Skip to content

Commit

Permalink
remove logging test (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsbrunson authored Jun 7, 2024
1 parent bdc0d4b commit bf05cf4
Showing 1 changed file with 1 addition and 32 deletions.
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 */

0 comments on commit bf05cf4

Please sign in to comment.