From 1c381eba15d28f57e3a73cee3b811965f75b512d Mon Sep 17 00:00:00 2001 From: Hai-Yen Nguyen Date: Mon, 23 Sep 2024 14:25:18 -0500 Subject: [PATCH] create a DEFAULT_BT_VERSION to 3.107.1 and update unit test: --- src/connect/component.jsx | 10 ++++++---- src/connect/component.test.js | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/connect/component.jsx b/src/connect/component.jsx index c63264f95..173be0bcb 100644 --- a/src/connect/component.jsx +++ b/src/connect/component.jsx @@ -16,13 +16,15 @@ import { import { FPTI_KEY } from "@paypal/sdk-constants"; const MIN_MAJOR_VERSION = 3; -const MIN_MINOR_VERSION = 107; -const MIN_PATCH_VERSION = 1; -export const MIN_BT_VERSION = `${MIN_MAJOR_VERSION}.${MIN_MINOR_VERSION}.${MIN_PATCH_VERSION}`; // Minimum for supporting AXO +const MIN_MINOR_VERSION = 97; +const MIN_PATCH_VERSION = 3; +export const MIN_BT_VERSION = `${MIN_MAJOR_VERSION}.${MIN_MINOR_VERSION}.${MIN_PATCH_VERSION}-connect-alpha.6.1`; // Minimum for supporting AXO + +export const DEFAULT_BT_VERSION = `3.107.1`; export function getSdkVersion(version: string | null): string { if (!version) { - return MIN_BT_VERSION; + return DEFAULT_BT_VERSION; } const versionSplit = version.split("."); // patch could have an alpha tag diff --git a/src/connect/component.test.js b/src/connect/component.test.js index fef462500..20a1cb25c 100644 --- a/src/connect/component.test.js +++ b/src/connect/component.test.js @@ -7,7 +7,7 @@ import { describe, expect, test, vi } from "vitest"; import { getConnectComponent, getSdkVersion, - MIN_BT_VERSION, + DEFAULT_BT_VERSION, } from "./component"; vi.mock("@paypal/sdk-client/src", () => { @@ -113,7 +113,7 @@ describe("getConnectComponent: returns ConnectComponent", () => { ); }); - test("minified is set according to debug value", async () => { + test("loadAxo is call with default values", async () => { await getConnectComponent(mockProps); expect(loadAxo).toHaveBeenCalledWith({ minified: true, @@ -128,26 +128,26 @@ describe("getSdkVersion", () => { test("returns minimum supported braintree version for AXO if input version is null", () => { const version = getSdkVersion(null); - expect(version).toEqual(MIN_BT_VERSION); + expect(version).toEqual(DEFAULT_BT_VERSION); }); test("returns the version passed if it is supported for AXO", () => { - const result1 = getSdkVersion("3.107.1"); - const result2 = getSdkVersion("3.107.1-alpha-test"); + const result2 = getSdkVersion("3.97.3-alpha-test"); const result3 = getSdkVersion("4.34.3-beta-test"); const result4 = getSdkVersion("4.34.47"); - const result5 = getSdkVersion("3.108.0"); + const result5 = getSdkVersion("3.98.3"); + const result6 = getSdkVersion("3.97.6"); - expect(result1).toEqual("3.107.1"); - expect(result2).toEqual("3.107.1-alpha-test"); + expect(result2).toEqual("3.97.3-alpha-test"); expect(result3).toEqual("4.34.3-beta-test"); expect(result4).toEqual("4.34.47"); - expect(result5).toEqual("3.108.0"); + expect(result5).toEqual("3.98.3"); + expect(result6).toEqual("3.97.6"); }); test("throws error if the version passed is not supported for AXO and is not null", () => { expect(() => getSdkVersion("3.96.00")).toThrowError(); - expect(() => getSdkVersion("2.87.2-alpha-test")).toThrowError(); - expect(() => getSdkVersion("3.34.1-beta-test")).toThrowError(); - expect(() => getSdkVersion("3.107.0-alpha-test")).toThrowError(); + expect(() => getSdkVersion("3.97.00")).toThrowError(); + expect(() => getSdkVersion("2.87.1-alpha-test")).toThrowError(); + expect(() => getSdkVersion("3.34.2-beta-test")).toThrowError(); }); });