Skip to content

Commit

Permalink
Revert "update axo loader library (#2350)" (#2353)
Browse files Browse the repository at this point in the history
This reverts commit bcdf9c3.
  • Loading branch information
wsbrunson committed Mar 5, 2024
1 parent 39b66ec commit 914d42d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
"@krakenjs/post-robot": "^11.0.0",
"@krakenjs/zalgo-promise": "^2.0.0",
"@krakenjs/zoid": "^10.3.1",
"@paypal/accelerated-checkout-loader": "^1.0.0",
"@paypal/common-components": "^1.0.35",
"@paypal/connect-loader-component": "1.1.1",
"@paypal/funding-components": "^1.0.31",
"@paypal/sdk-client": "^4.0.181",
"@paypal/sdk-constants": "^1.0.141",
Expand Down
2 changes: 1 addition & 1 deletion src/connect/component.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @flow */
import { loadAxo } from "@paypal/accelerated-checkout-loader/dist/loader.esm";
import { loadAxo } from "@paypal/connect-loader-component";
import { stringifyError } from "@krakenjs/belter/src";
import {
getClientID,
Expand Down
15 changes: 10 additions & 5 deletions src/connect/component.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* @flow */

import { getUserIDToken, getSDKToken } from "@paypal/sdk-client/src";
// eslint-disable-next-line import/no-namespace
import * as axo from "@paypal/accelerated-checkout-loader/dist/loader.esm";
import { loadAxo } from "@paypal/connect-loader-component";
import { describe, expect, test, vi } from "vitest";

import {
Expand Down Expand Up @@ -31,6 +30,12 @@ vi.mock("@paypal/sdk-client/src", () => {
};
});

vi.mock("@paypal/connect-loader-component", () => {
return {
loadAxo: vi.fn(),
};
});

describe("getConnectComponent: returns ConnectComponent", () => {
const mockAxoMetadata = { someData: "data" };
const mockProps = { someProp: "value" };
Expand All @@ -43,7 +48,7 @@ describe("getConnectComponent: returns ConnectComponent", () => {
},
};

vi.spyOn(axo, "loadAxo").mockResolvedValue({ metadata: mockAxoMetadata });
loadAxo.mockResolvedValue({ metadata: mockAxoMetadata });
});

test("uses user id token if no sdk token is present", async () => {
Expand Down Expand Up @@ -92,7 +97,7 @@ describe("getConnectComponent: returns ConnectComponent", () => {

test("loadAxo failure is handled", async () => {
const errorMessage = "Something went wrong";
axo.loadAxo.mockRejectedValue(errorMessage);
loadAxo.mockRejectedValue(errorMessage);

await expect(() => getConnectComponent(mockProps)).rejects.toThrow(
errorMessage
Expand All @@ -110,7 +115,7 @@ describe("getConnectComponent: returns ConnectComponent", () => {

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

0 comments on commit 914d42d

Please sign in to comment.