Skip to content

Commit

Permalink
add debug support for axo (#2292)
Browse files Browse the repository at this point in the history
* add debug support for axo

* update cmid param to support axo reqrmnt
  • Loading branch information
siddy2181 authored Dec 15, 2023
1 parent bc94877 commit d858f23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions 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 { FPTI_KEY } from "@paypal/sdk-constants";

Expand All @@ -21,14 +22,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 Expand Up @@ -60,7 +62,7 @@ export const getConnectComponent = async (merchantProps) => {
platform: "PPCP",
userIdToken,
clientID,
clientMetadataID: cmid,
clientMetadataId: cmid,
},
});
getLogger()
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 d858f23

Please sign in to comment.