Skip to content

Commit cfb9887

Browse files
authored
feat: add version to PayPalV6Namespace (#718)
* add PayPalV6Namespace global * add paypal global union type tests * remove extra spaces * add changeset * fix lint errors * add version to PayPalV6Namespace * convert pr to just adding version to PayPalV6Namespace * add tests * remove unused tests
1 parent 249f1e3 commit cfb9887

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@paypal/paypal-js": patch
3+
---
4+
5+
feat: add version to PayPalV6Namespace

packages/paypal-js/src/v6/index.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,15 @@ describe("loadCoreSdkScript()", () => {
9494
});
9595
});
9696

97-
test("should error due to invalid input", async () => {
97+
test("should return PayPal namespace with version property", async () => {
98+
const result = await loadCoreSdkScript();
99+
expect(result).toBeDefined();
100+
expect(result.version).toBeDefined();
101+
expect(result.version).toBe("6");
102+
expect(typeof result.version).toBe("string");
103+
});
104+
105+
test("should error due to unvalid input", async () => {
98106
expect(async () => {
99107
// @ts-expect-error invalid arguments
100108
await loadCoreSdkScript(123);

packages/paypal-js/types/v6/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface PayPalV6Namespace {
3030
createInstance: <T extends readonly [Components, ...Components[]]>(
3131
createInstanceOptions: CreateInstanceOptions<T>,
3232
) => Promise<SdkInstance<T>>;
33+
version: `${number}.${number}.${number}`;
3334
}
3435

3536
export type Components =

packages/paypal-js/types/v6/tests/paypal-legacy-billing-agreements.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ async function main() {
2121
throw new Error("Invalid paypal object for v6");
2222
}
2323

24+
if (!paypal?.version) {
25+
throw new Error("PayPal v6 namespace missing version property");
26+
}
27+
2428
const sdkInstance = await paypal.createInstance({
2529
clientToken: "fakeValue",
2630
components: ["paypal-legacy-billing-agreements"],

packages/paypal-js/types/v6/tests/paypal-payments.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ async function main() {
1818
throw new Error("Invalid paypal object for v6");
1919
}
2020

21+
if (!paypal?.version) {
22+
throw new Error("PayPal v6 namespace missing version property");
23+
}
24+
2125
const sdkInstance = await paypal.createInstance({
2226
clientToken: "fakeValue",
2327
components: ["paypal-payments"],

packages/paypal-js/types/v6/tests/venmo-payments.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ async function main() {
1818
throw new Error("Invalid paypal object for v6");
1919
}
2020

21+
if (!paypal?.version) {
22+
throw new Error("PayPal v6 namespace missing version property");
23+
}
24+
2125
const sdkInstance = await paypal.createInstance({
2226
clientToken: "fakeValue",
2327
components: ["venmo-payments"],

0 commit comments

Comments
 (0)