mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-03-10 08:01:20 +00:00
fix linting warnings for using "any" as type (#927)
This commit is contained in:
@@ -60,7 +60,7 @@ describe("Bin Lookup", function (): void {
|
||||
try {
|
||||
await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as IBinLookup.ThreeDSAvailabilityRequest);
|
||||
fail("Expected request to fail");
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
expect(e instanceof HttpClientException).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -253,7 +253,7 @@ describe("Checkout", (): void => {
|
||||
|
||||
const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest();
|
||||
await checkout.payments(paymentsRequest);
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
expect(e instanceof HttpClientException).toBeTruthy();
|
||||
}
|
||||
});
|
||||
@@ -347,8 +347,13 @@ describe("Checkout", (): void => {
|
||||
try {
|
||||
new Checkout(client);
|
||||
fail();
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
expect(e.message).toEqual("Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.");
|
||||
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -101,8 +101,12 @@ describe("HMAC Validator", function (): void {
|
||||
};
|
||||
try {
|
||||
hmacValidator.validateHMAC(notificationRequestItemNoAdditionalData, key);
|
||||
} catch(error: any) {
|
||||
expect(error.message).toEqual(`Missing ${ApiConstants.HMAC_SIGNATURE}`);
|
||||
} catch(error) {
|
||||
if(error instanceof Error) {
|
||||
expect(error.message).toEqual(`Missing ${ApiConstants.HMAC_SIGNATURE}`);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -43,10 +43,14 @@ const getResponse = async ({apiKey , environment }: { apiKey: string; environmen
|
||||
try {
|
||||
await checkout.payments(createPaymentsCheckoutRequest());
|
||||
fail("request should fail");
|
||||
} catch (e: any) {
|
||||
expect(e instanceof ErrorException).toBeTruthy();
|
||||
if (errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
||||
if (errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
||||
} catch (e) {
|
||||
if(e instanceof ErrorException){
|
||||
if (errorMessageEquals) expect(e.message).toEqual(errorMessageEquals);
|
||||
if (errorMessageContains) expect(e.message.toLowerCase()).toContain(errorMessageContains);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
PaymentCaptureResource, PaymentRefundResource, PaymentReversalResource,
|
||||
StandalonePaymentCancelResource
|
||||
} from "../typings/checkout/models";
|
||||
import HttpClientException from "../httpClient/httpClientException";
|
||||
|
||||
const invalidModificationResult = {
|
||||
"status": 422,
|
||||
@@ -177,8 +178,12 @@ describe("Modification", (): void => {
|
||||
try {
|
||||
const result = await checkout.amountUpdates(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
if(e.message) fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -191,9 +196,13 @@ describe("Modification", (): void => {
|
||||
|
||||
try {
|
||||
await checkout.amountUpdates(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -205,8 +214,12 @@ describe("Modification", (): void => {
|
||||
try {
|
||||
const result = await checkout.cancels(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -218,9 +231,13 @@ describe("Modification", (): void => {
|
||||
.reply(422, invalidModificationResult);
|
||||
try {
|
||||
await checkout.cancels(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -232,8 +249,12 @@ describe("Modification", (): void => {
|
||||
try {
|
||||
const result = await checkout.cancelsStandalone(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -245,8 +266,12 @@ describe("Modification", (): void => {
|
||||
try {
|
||||
const result = await checkout.captures(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -258,9 +283,13 @@ describe("Modification", (): void => {
|
||||
.reply(422, invalidModificationResult);
|
||||
try {
|
||||
await checkout.captures(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
if(e.message) expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -272,8 +301,12 @@ describe("Modification", (): void => {
|
||||
try {
|
||||
const result = await checkout.refunds(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
if(e.message) fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -285,9 +318,13 @@ describe("Modification", (): void => {
|
||||
.reply(422, invalidModificationResult);
|
||||
try {
|
||||
await checkout.refunds(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -299,8 +336,12 @@ describe("Modification", (): void => {
|
||||
try {
|
||||
const result = await checkout.reversals(paymentPspReference, request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
if(e instanceof Error) {
|
||||
if(e.message) fail(e.message);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -312,9 +353,13 @@ describe("Modification", (): void => {
|
||||
.reply(422, invalidModificationResult);
|
||||
try {
|
||||
await checkout.reversals(invalidPaymentPspReference, request);
|
||||
} catch (e: any) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
if(e.statusCode) expect(e.statusCode).toBe(422);
|
||||
expect(e.message).toContain("Original pspReference required for this operation");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -247,8 +247,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
nock.restore();
|
||||
try {
|
||||
expect(accountHolder.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
it("should get account holder", async function() {
|
||||
@@ -258,8 +262,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: accountHolder.accountHolderCode,
|
||||
});
|
||||
expect(result.accountHolderDetails.email).toEqual("random_email@example.com");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -276,8 +284,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
}
|
||||
});
|
||||
expect(result.accountHolderDetails!.address?.country).toEqual("BE");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -290,8 +302,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
tier: 2
|
||||
});
|
||||
expect(result.resultCode).toEqual("Success");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -299,8 +315,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
nock.restore();
|
||||
try {
|
||||
expect(account.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -317,8 +337,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
}
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -338,8 +362,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: account.accountHolderCode,
|
||||
});
|
||||
expect(result.documentDetails![0].filename).toEqual("IDCardFront.png");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -350,8 +378,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountCode: accountToClose.accountCode
|
||||
});
|
||||
expect(result.status).toEqual("Closed");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -362,8 +394,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: accountHolderToSuspend.accountHolderCode,
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -372,8 +408,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
try {
|
||||
const result = await platforms.Account.unSuspendAccountHolder({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode });
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -386,8 +426,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
stateType: A.UpdateAccountHolderStateRequest.StateTypeEnum.Payout
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -398,8 +442,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: accountHolderToClose.accountHolderCode
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -412,9 +460,13 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
year: 2020
|
||||
});
|
||||
expect(result.content).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
}
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -426,8 +478,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: generateRandomCode()
|
||||
});
|
||||
expect(result.balancePerAccount![0].detailBalance).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -438,8 +494,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
accountHolderCode: generateRandomCode()
|
||||
});
|
||||
expect(result.accountTransactionLists![0].transactions).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -456,8 +516,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
transferCode: "SUBSCRIPTION"
|
||||
});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -471,8 +535,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
const result = await platforms.NotificationConfiguration.getNotificationConfigurationList({});
|
||||
const resultStr = JSON.stringify(result);
|
||||
expect(resultStr.includes("pspReference")).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -486,8 +554,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
}
|
||||
});
|
||||
expect(result.configurationDetails.active).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -499,8 +571,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
notificationId: configurationID
|
||||
});
|
||||
expect(result.configurationDetails.notifyURL).toEqual("https://www.adyen.com/notification-handler");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -525,8 +601,12 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
});
|
||||
const accountHolderVerification = result.configurationDetails.eventConfigs.filter(event => event.eventType === "ACCOUNT_HOLDER_VERIFICATION")[0];
|
||||
expect(accountHolderVerification.includeMode).toEqual("EXCLUDE");
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -537,9 +617,13 @@ describe.skip("Platforms Test E2E", function(): void {
|
||||
try {
|
||||
const result = await platforms.NotificationConfiguration.deleteNotificationConfigurations({notificationIds});
|
||||
expect(result.pspReference).toBeDefined();
|
||||
} catch (e: any) {
|
||||
assertError(e);
|
||||
}
|
||||
} catch (e) {
|
||||
if(e instanceof HttpClientException) {
|
||||
assertError(e);
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -76,8 +76,8 @@ describe("Recurring", (): void => {
|
||||
try {
|
||||
const result = await recurring.disable(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -101,8 +101,8 @@ describe("Recurring", (): void => {
|
||||
try {
|
||||
const result = await recurring.notifyShopper(notifyShopperRequest);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -130,8 +130,8 @@ describe("Recurring", (): void => {
|
||||
try {
|
||||
const result = await recurring.scheduleAccountUpdater(request);
|
||||
expect(result).toBeTruthy();
|
||||
} catch (e: any) {
|
||||
fail(e.message);
|
||||
} catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,9 +79,13 @@ describe("Terminal Local API", (): void => {
|
||||
|
||||
try {
|
||||
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey);
|
||||
} catch (e: any) {
|
||||
expect(e instanceof NexoCryptoException);
|
||||
expect(e.message).toEqual("Hmac validation failed");
|
||||
} catch (e) {
|
||||
if(e instanceof NexoCryptoException) {
|
||||
expect(e.message).toEqual("Hmac validation failed");
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -195,8 +195,9 @@ class HttpURLConnectionClient implements ClientInterface {
|
||||
checkServerIdentity,
|
||||
};
|
||||
|
||||
} catch (e: any) {
|
||||
return Promise.reject(new HttpClientException({ message: `Error loading certificate from path: ${e.message}` }));
|
||||
} catch (e) {
|
||||
const message = e instanceof Error ? e.message: "undefined";
|
||||
return Promise.reject(new HttpClientException({ message: `Error loading certificate from path: ${message}` }));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user