Skip to content

Commit

Permalink
add debug support for axo
Browse files Browse the repository at this point in the history
  • Loading branch information
siddy2181 committed Dec 11, 2023
1 parent 8db2962 commit 4716257
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/connect/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getClientMetadataID,
getUserIDToken,
getLogger,
getDebug,
} from "@paypal/sdk-client/src";

import { sendCountMetric } from "./sendCountMetric";
Expand All @@ -20,14 +21,15 @@ export const getConnectComponent = async (merchantProps) => {
const cmid = getClientMetadataID();
const clientID = getClientID();
const userIdToken = getUserIDToken();
const debugEnabled = getDebug() || false;
const { metadata } = merchantProps;

let loadResult = {};
try {
loadResult = await loadAxo({
platform: "PPCP",
btSdkVersion: "3.97.3-connect-alpha.6.1",
minified: true,
minified: !debugEnabled,
metadata,
});
} catch (error) {
Expand Down
11 changes: 11 additions & 0 deletions src/connect/component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ vi.mock("@paypal/sdk-client/src", () => {
getClientID: vi.fn(() => "mock-client-id"),
getClientMetadataID: vi.fn(() => "mock-cmid"),
getUserIDToken: vi.fn(() => "mock-uid"),
getDebug: vi.fn(() => false),
getLogger: vi.fn(() => ({ metric: vi.fn(), error: vi.fn() })),
};
});
Expand Down Expand Up @@ -86,4 +87,14 @@ describe("getConnectComponent: returns ConnectComponent", () => {
);
expect(sendCountMetric).toBeCalledTimes(2);
});

test("minified is set according to debug value", async () => {
await getConnectComponent(mockProps);
expect(loadAxo).toHaveBeenCalledWith({
minified: true,
btSdkVersion: "3.97.3-connect-alpha.6.1",
metadata: undefined,
platform: "PPCP",
});
});
});

0 comments on commit 4716257

Please sign in to comment.