From 3a85b49be9ff598c86418ead64e13e487fac9541 Mon Sep 17 00:00:00 2001 From: Beppe Catanese Date: Tue, 13 May 2025 14:29:14 +0200 Subject: [PATCH 1/2] Use LibraryConstants values in unit tests --- src/__tests__/httpClient.spec.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/__tests__/httpClient.spec.ts b/src/__tests__/httpClient.spec.ts index 77f828e0b..f55f8631e 100644 --- a/src/__tests__/httpClient.spec.ts +++ b/src/__tests__/httpClient.spec.ts @@ -8,6 +8,8 @@ import { binlookup } from "../typings"; import { ApiConstants } from "../constants/apiConstants"; import {paymentMethodsSuccess} from "../__mocks__/checkout/paymentMethodsSuccess"; import Config from "../config"; +import LibraryConstants from "../constants/libraryConstants"; + beforeEach((): void => { nock.cleanAll(); @@ -108,9 +110,9 @@ describe("HTTP Client", function (): void { const client = createClient(); const checkout = new CheckoutAPI(client); - const expectedUserAgent = `adyen-node-api-library/26.1.0`; - const expectedLibraryName = `adyen-node-api-library`; - const expectedLibraryVersion = `26.1.0`; + const expectedUserAgent = LibraryConstants.LIB_NAME + `/` + LibraryConstants.LIB_VERSION; + const expectedLibraryName = LibraryConstants.LIB_NAME; + const expectedLibraryVersion = LibraryConstants.LIB_VERSION; const scope = nock("https://checkout-test.adyen.com/v71", { reqheaders: { @@ -145,9 +147,9 @@ describe("HTTP Client", function (): void { client.config.applicationName = "testApp"; const checkout = new CheckoutAPI(client); - const expectedUserAgent = `testApp adyen-node-api-library/26.1.0`; // include applicationName too - const expectedLibraryName = `adyen-node-api-library`; - const expectedLibraryVersion = `26.1.0`; + const expectedUserAgent = `testApp ` + LibraryConstants.LIB_NAME + `/` + LibraryConstants.LIB_VERSION; // include applicationName too + const expectedLibraryName = LibraryConstants.LIB_NAME; + const expectedLibraryVersion = LibraryConstants.LIB_VERSION; const scope = nock("https://checkout-test.adyen.com/v71", { reqheaders: { From 24c7a23f19548913db4a4f68b1aff328776d7179 Mon Sep 17 00:00:00 2001 From: Beppe Catanese Date: Tue, 13 May 2025 14:40:04 +0200 Subject: [PATCH 2/2] Use template literals instead of str concatenation --- src/__tests__/httpClient.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/__tests__/httpClient.spec.ts b/src/__tests__/httpClient.spec.ts index f55f8631e..e8e2e1f23 100644 --- a/src/__tests__/httpClient.spec.ts +++ b/src/__tests__/httpClient.spec.ts @@ -110,7 +110,7 @@ describe("HTTP Client", function (): void { const client = createClient(); const checkout = new CheckoutAPI(client); - const expectedUserAgent = LibraryConstants.LIB_NAME + `/` + LibraryConstants.LIB_VERSION; + const expectedUserAgent = `${LibraryConstants.LIB_NAME}/${LibraryConstants.LIB_VERSION}`; const expectedLibraryName = LibraryConstants.LIB_NAME; const expectedLibraryVersion = LibraryConstants.LIB_VERSION; @@ -147,7 +147,7 @@ describe("HTTP Client", function (): void { client.config.applicationName = "testApp"; const checkout = new CheckoutAPI(client); - const expectedUserAgent = `testApp ` + LibraryConstants.LIB_NAME + `/` + LibraryConstants.LIB_VERSION; // include applicationName too + const expectedUserAgent = `testApp ${LibraryConstants.LIB_NAME}/${LibraryConstants.LIB_VERSION}`; // include applicationName too const expectedLibraryName = LibraryConstants.LIB_NAME; const expectedLibraryVersion = LibraryConstants.LIB_VERSION;