From 3a7e75a09058382838d5ceea3e3e463860d3d37c Mon Sep 17 00:00:00 2001 From: Shane Brunson Date: Wed, 6 Mar 2024 10:01:50 -0600 Subject: [PATCH] Revert "Revert "update axo loader library (#2350)" (#2353)" This reverts commit 914d42dfcf9d7a1b41f8bf70c674dbd9d768f4d4. --- package.json | 2 +- src/connect/component.jsx | 2 +- src/connect/component.test.js | 15 +++++---------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index b057744554..ec7dfc4c7a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/connect/component.jsx b/src/connect/component.jsx index 8370249a1f..98cd38d5a9 100644 --- a/src/connect/component.jsx +++ b/src/connect/component.jsx @@ -1,5 +1,5 @@ /* @flow */ -import { loadAxo } from "@paypal/connect-loader-component"; +import { loadAxo } from "@paypal/accelerated-checkout-loader/dist/loader.esm"; import { stringifyError } from "@krakenjs/belter/src"; import { getClientID, diff --git a/src/connect/component.test.js b/src/connect/component.test.js index d7e0e71c64..e7ce079b84 100644 --- a/src/connect/component.test.js +++ b/src/connect/component.test.js @@ -1,7 +1,8 @@ /* @flow */ import { getUserIDToken, getSDKToken } from "@paypal/sdk-client/src"; -import { loadAxo } from "@paypal/connect-loader-component"; +// eslint-disable-next-line import/no-namespace +import * as axo from "@paypal/accelerated-checkout-loader/dist/loader.esm"; import { describe, expect, test, vi } from "vitest"; import { @@ -30,12 +31,6 @@ 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" }; @@ -48,7 +43,7 @@ describe("getConnectComponent: returns ConnectComponent", () => { }, }; - loadAxo.mockResolvedValue({ metadata: mockAxoMetadata }); + vi.spyOn(axo, "loadAxo").mockResolvedValue({ metadata: mockAxoMetadata }); }); test("uses user id token if no sdk token is present", async () => { @@ -97,7 +92,7 @@ describe("getConnectComponent: returns ConnectComponent", () => { test("loadAxo failure is handled", async () => { const errorMessage = "Something went wrong"; - loadAxo.mockRejectedValue(errorMessage); + axo.loadAxo.mockRejectedValue(errorMessage); await expect(() => getConnectComponent(mockProps)).rejects.toThrow( errorMessage @@ -115,7 +110,7 @@ describe("getConnectComponent: returns ConnectComponent", () => { test("minified is set according to debug value", async () => { await getConnectComponent(mockProps); - expect(loadAxo).toHaveBeenCalledWith({ + expect(axo.loadAxo).toHaveBeenCalledWith({ minified: true, btSdkVersion: "3.97.3-connect-alpha.6.1", metadata: undefined,