Skip to content

Commit

Permalink
use loader.esm
Browse files Browse the repository at this point in the history
  • Loading branch information
wsbrunson committed Mar 1, 2024
1 parent 2de6242 commit be307d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
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";
import { loadAxo } from "@paypal/accelerated-checkout-loader/dist/loader.esm";
import { stringifyError } from "@krakenjs/belter/src";
import {
getClientID,
Expand Down
14 changes: 4 additions & 10 deletions src/connect/component.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @flow */

import { getUserIDToken, getSDKToken } from "@paypal/sdk-client/src";
import { loadAxo } from "@paypal/accelerated-checkout-loader";
import * as axo from "@paypal/accelerated-checkout-loader/dist/loader.esm";

Check failure on line 4 in src/connect/component.test.js

View workflow job for this annotation

GitHub Actions / main

Unexpected namespace import
import { describe, expect, test, vi } from "vitest";

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

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

describe("getConnectComponent: returns ConnectComponent", () => {
const mockAxoMetadata = { someData: "data" };
const mockProps = { someProp: "value" };
Expand All @@ -48,7 +42,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 () => {
Expand Down Expand Up @@ -97,7 +91,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
Expand All @@ -115,7 +109,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,
Expand Down

0 comments on commit be307d8

Please sign in to comment.