Skip to content

Commit

Permalink
Add getJsSdkLibrary() test
Browse files Browse the repository at this point in the history
  • Loading branch information
nbierdeman committed Mar 12, 2024
1 parent 93fa3bd commit 01d046e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/script.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint max-lines: off */
import { describe, it, afterEach, beforeEach, expect, vi } from "vitest";
import { base64encode, getCurrentScript, memoize } from "@krakenjs/belter/src";
import { JS_SDK_LIBRARIES } from "@paypal/sdk-constants/src";

import { makeMockScriptElement } from "../test/helpers";

Expand All @@ -16,6 +17,7 @@ import {
getMerchantID,
getClientAccessToken,
getSDKIntegrationSource,
getJsSdkLibrary,
getPageType,
getLocale,
getMerchantRequestedPopupsDisabled,
Expand Down Expand Up @@ -253,6 +255,16 @@ describe(`script cases`, () => {
expect(getSDKIntegrationSource()).toEqual(SDKIntegrationSource);
});

it("should successfully get js sdk library", () => {
const jsSdkLibrary = JS_SDK_LIBRARIES.REACT_PAYPAL_JS;
const mockElement = makeMockScriptElement(mockScriptSrc);
mockElement.setAttribute("data-js-sdk-library", jsSdkLibrary);
// $FlowIgnore
getCurrentScript.mockReturnValue(mockElement);

expect(getJsSdkLibrary()).toEqual(jsSdkLibrary);
});

it("should successfully get popup disabled attribute as true when set to true", () => {
const popupsDisabled = true;
const mockElement = makeMockScriptElement(mockScriptSrc);
Expand Down

0 comments on commit 01d046e

Please sign in to comment.