Skip to content

Commit 6359f9c

Browse files
committed
Add tests for TransferLimitsBalancePlatformLevelApi
1 parent b701639 commit 6359f9c

File tree

1 file changed

+192
-62
lines changed

1 file changed

+192
-62
lines changed

src/__tests__/balancePlatform.spec.ts

Lines changed: 192 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import nock from "nock";
22
import Client from "../client";
33
import { createClient } from "../__mocks__/base";
44
import BalancePlatform from "../services/balancePlatform";
5-
import { balancePlatform } from "../typings";
6-
import {IRequest} from "../typings/requestOptions";
5+
import { balancePlatform } from "../typings";
6+
import { IRequest } from "../typings/requestOptions";
77
import { BalanceWebhookSettingInfo } from "../typings/balancePlatform/balanceWebhookSettingInfo";
88
import { Target } from "../typings/balancePlatform/target";
99
import { TransferRouteRequest } from "../typings/balancePlatform/transferRouteRequest";
1010
import { IbanAccountIdentification } from "../typings/balancePlatform/ibanAccountIdentification";
1111
import { Condition } from "../typings/balancePlatform/condition";
1212
import { Scope } from "../typings/balancePlatform/scope";
13+
import { LimitStatus } from "../typings/balancePlatform/models";
1314
import { TransferType } from "../typings/balancePlatform/transferType";
1415

1516
let client: Client;
@@ -349,17 +350,17 @@ describe("Balance Platform", (): void => {
349350
"type": "pull",
350351
"status": "inactive"
351352
});
352-
const request: balancePlatform.SweepConfigurationV2 = {
353-
"id": sweepId,
354-
"counterparty": {
355-
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
356-
},
357-
"status": balancePlatform.SweepConfigurationV2.StatusEnum.Inactive,
358-
"currency": "EUR",
359-
"schedule": {
360-
"type": balancePlatform.SweepSchedule.TypeEnum.Cron
361-
}
362-
};
353+
const request: balancePlatform.SweepConfigurationV2 = {
354+
"id": sweepId,
355+
"counterparty": {
356+
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
357+
},
358+
"status": balancePlatform.SweepConfigurationV2.StatusEnum.Inactive,
359+
"currency": "EUR",
360+
"schedule": {
361+
"type": balancePlatform.SweepSchedule.TypeEnum.Cron
362+
}
363+
};
363364

364365
const response: balancePlatform.SweepConfigurationV2 = await balancePlatformService.BalanceAccountsApi.updateSweep(balanceAccountId, sweepId, request);
365366

@@ -1035,34 +1036,34 @@ describe("Balance Platform", (): void => {
10351036
expect(response).toBeTruthy();
10361037
expect(response.transferRoutes).toBeTruthy();
10371038
expect(response.transferRoutes?.length).toBe(2);
1038-
});
1039+
});
10391040

10401041
it("should support GET /balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings", async (): Promise<void> => {
10411042
const balancePlatformId = "123456789";
10421043
const webhookId = "WH00000001";
10431044

10441045
const mockResponse = {
10451046
"webhookSettings": [
1046-
{
1047-
"id": "BWHS00000000000000000000000001",
1048-
"type": "balance",
1049-
"target": {
1050-
"type": "balancePlatform",
1051-
"id": "YOUR_BALANCE_PLATFORM"
1052-
},
1053-
"currency": "USD",
1054-
"status": "active"
1055-
},
1056-
{
1057-
"id": "BWHS00000000000000000000000002",
1058-
"type": "balance",
1059-
"target": {
1060-
"type": "balanceAccount",
1061-
"id": "BA00000000000000000LIABLE"
1047+
{
1048+
"id": "BWHS00000000000000000000000001",
1049+
"type": "balance",
1050+
"target": {
1051+
"type": "balancePlatform",
1052+
"id": "YOUR_BALANCE_PLATFORM"
1053+
},
1054+
"currency": "USD",
1055+
"status": "active"
10621056
},
1063-
"currency": "USD",
1064-
"status": "active"
1065-
}
1057+
{
1058+
"id": "BWHS00000000000000000000000002",
1059+
"type": "balance",
1060+
"target": {
1061+
"type": "balanceAccount",
1062+
"id": "BA00000000000000000LIABLE"
1063+
},
1064+
"currency": "USD",
1065+
"status": "active"
1066+
}
10661067
]
10671068
};
10681069

@@ -1222,7 +1223,7 @@ describe("Balance Platform", (): void => {
12221223
"endsAt": "2026-08-13T23:00:00+01:00",
12231224
"limitStatus": "pendingSCA",
12241225
"transferType": "all"
1225-
};
1226+
};
12261227

12271228
scope.post(`/balanceAccounts/${balanceAccountId}/transferLimits`)
12281229
.reply(200, mockResponse);
@@ -1258,20 +1259,20 @@ describe("Balance Platform", (): void => {
12581259
it("should support GET /balanceAccounts/{id}/transferLimits/current", async (): Promise<void> => {
12591260

12601261
const mockResponse = {
1261-
"transferLimits": [
1262-
{
1263-
"id": transferLimitId,
1264-
"limit": {
1265-
"currency": "EUR",
1266-
"value": 10000
1267-
},
1268-
"type": "maxUsage",
1269-
"counterparty": {
1270-
"balanceAccountId": "BA3227C223222B5CMD3FJFKGZ"
1271-
}
1262+
"transferLimits": [
1263+
{
1264+
"id": transferLimitId,
1265+
"limit": {
1266+
"currency": "EUR",
1267+
"value": 10000
1268+
},
1269+
"type": "maxUsage",
1270+
"counterparty": {
1271+
"balanceAccountId": "BA3227C223222B5CMD3FJFKGZ"
12721272
}
1273-
]
1274-
}
1273+
}
1274+
]
1275+
}
12751276

12761277
scope.get(`/balanceAccounts/${balanceAccountId}/transferLimits/current?scope=perTransaction&transferType=instant`)
12771278
.reply(200, mockResponse);
@@ -1285,16 +1286,16 @@ describe("Balance Platform", (): void => {
12851286
it("should support GET /balanceAccounts/{id}/transferLimits/{transferLimitId}", async (): Promise<void> => {
12861287

12871288
const mockResponse = {
1288-
"id": transferLimitId,
1289-
"limit": {
1290-
"currency": "EUR",
1291-
"value": 10000
1292-
},
1293-
"type": "maxUsage",
1294-
"counterparty": {
1295-
"balanceAccountId": "BA3227C223222B5CMD3FJFKGZ"
1296-
}
1289+
"id": transferLimitId,
1290+
"limit": {
1291+
"currency": "EUR",
1292+
"value": 10000
1293+
},
1294+
"type": "maxUsage",
1295+
"counterparty": {
1296+
"balanceAccountId": "BA3227C223222B5CMD3FJFKGZ"
12971297
}
1298+
}
12981299

12991300
scope.get(`/balanceAccounts/${balanceAccountId}/transferLimits/${transferLimitId}`)
13001301
.reply(200, mockResponse);
@@ -1307,12 +1308,12 @@ describe("Balance Platform", (): void => {
13071308
it("should support GET /balanceAccounts/{id}/transferLimits", async (): Promise<void> => {
13081309

13091310
const mockResponse = {
1310-
"transferLimits": [
1311-
{
1312-
"id": transferLimitId,
1313-
}
1314-
]
1315-
}
1311+
"transferLimits": [
1312+
{
1313+
"id": transferLimitId,
1314+
}
1315+
]
1316+
}
13161317
scope.get(`/balanceAccounts/${balanceAccountId}/transferLimits?scope=perTransaction&transferType=instant&status=active`)
13171318
.reply(200, mockResponse);
13181319

@@ -1323,4 +1324,133 @@ describe("Balance Platform", (): void => {
13231324
});
13241325
});
13251326

1327+
describe("TransferLimitsBalancePlatformLevelApi", (): void => {
1328+
const balancePlatformId = "BP32272223222B59CZ3T52DKZ";
1329+
1330+
it("should support POST /balancePlatforms/{id}/transferLimits", async (): Promise<void> => {
1331+
const mockResponse = {
1332+
"amount": {
1333+
"value": 10000,
1334+
"currency": "EUR"
1335+
},
1336+
"id": "TRLI00000000000000000000000001",
1337+
"scope": "perTransaction",
1338+
"reference": "Your reference for the transfer limit",
1339+
"scaInformation": {
1340+
"status": "pending"
1341+
},
1342+
"startsAt": "2025-08-15T06:36:20+01:00",
1343+
"endsAt": "2026-08-13T23:00:00+01:00",
1344+
"limitStatus": "pendingSCA",
1345+
"transferType": "all"
1346+
};
1347+
1348+
scope.post(`/balancePlatforms/${balancePlatformId}/transferLimits`)
1349+
.reply(200, mockResponse);
1350+
1351+
const request: balancePlatform.CreateTransferLimitRequest = {
1352+
"amount": {
1353+
"currency": "EUR",
1354+
"value": 10000
1355+
},
1356+
"reference": "Your reference for the transfer limit",
1357+
"scaInformation": {
1358+
"scaOnApproval": true
1359+
},
1360+
"scope": Scope.PerTransaction,
1361+
"startsAt": new Date("2025-08-15T06:36:20+01:00"),
1362+
"endsAt": new Date("2026-08-14T00:00:00+01:00"),
1363+
"transferType": TransferType.All
1364+
};
1365+
1366+
const response: balancePlatform.TransferLimit = await balancePlatformService.TransferLimitsBalancePlatformLevelApi.createTransferLimit(balancePlatformId, request);
1367+
1368+
expect(response.id).toBe("TRLI00000000000000000000000001");
1369+
expect(response.limitStatus).toBe("pendingSCA");
1370+
expect(response.amount.value).toBe(10000);
1371+
});
1372+
1373+
it("should support DELETE /balancePlatforms/{id}/transferLimits/{transferLimitId}", async (): Promise<void> => {
1374+
scope.delete(`/balancePlatforms/${balancePlatformId}/transferLimits/${transferLimitId}`).reply(204);
1375+
1376+
await balancePlatformService.TransferLimitsBalancePlatformLevelApi.deletePendingTransferLimit(transferLimitId, balancePlatformId);
1377+
});
1378+
1379+
it("should support GET /balancePlatforms/{id}/transferLimits/{transferLimitId}", async (): Promise<void> => {
1380+
const mockResponse = {
1381+
"amount": {
1382+
"value": 10000,
1383+
"currency": "EUR"
1384+
},
1385+
"id": "TRLI00000000000000000000000001",
1386+
"endsAt": "2026-08-13T23:00:00+01:00",
1387+
"scope": "perTransaction",
1388+
"reference": "Your reference for the transfer limit",
1389+
"scaInformation": {
1390+
"exemption": "initialLimit",
1391+
"status": "notPerformed"
1392+
},
1393+
"startsAt": "2025-08-13T23:00:00+01:00",
1394+
"limitStatus": "active",
1395+
"transferType": "all"
1396+
};
1397+
1398+
scope.get(`/balancePlatforms/${balancePlatformId}/transferLimits/${transferLimitId}`)
1399+
.reply(200, mockResponse);
1400+
1401+
const response: balancePlatform.TransferLimit = await balancePlatformService.TransferLimitsBalancePlatformLevelApi.getSpecificTransferLimit(transferLimitId, balancePlatformId);
1402+
1403+
expect(response.id).toBe("TRLI00000000000000000000000001");
1404+
});
1405+
1406+
it("should support GET /balancePlatforms/{id}/transferLimits", async (): Promise<void> => {
1407+
const mockResponse = {
1408+
"transferLimits": [
1409+
{
1410+
"amount": {
1411+
"value": 10000,
1412+
"currency": "EUR"
1413+
},
1414+
"id": "TRLI00000000000000000000000001",
1415+
"endsAt": "2026-08-13T23:00:00+01:00",
1416+
"scope": "perTransaction",
1417+
"reference": "Your reference for the transfer limit",
1418+
"scaInformation": {
1419+
"exemption": "initialLimit",
1420+
"status": "notPerformed"
1421+
},
1422+
"startsAt": "2025-08-13T23:00:00+01:00",
1423+
"limitStatus": "active",
1424+
"transferType": "instant"
1425+
},
1426+
{
1427+
"amount": {
1428+
"value": 20000,
1429+
"currency": "EUR"
1430+
},
1431+
"id": "TRLI00000000000000000000000002",
1432+
"endsAt": "2026-08-13T23:00:00+01:00",
1433+
"scope": "perTransaction",
1434+
"reference": "Your reference for the transfer limit",
1435+
"scaInformation": {
1436+
"exemption": "initialLimit",
1437+
"status": "notPerformed"
1438+
},
1439+
"startsAt": "2025-08-13T23:00:00+01:00",
1440+
"limitStatus": "active",
1441+
"transferType": "all"
1442+
}
1443+
]
1444+
};
1445+
scope.get(`/balancePlatforms/${balancePlatformId}/transferLimits?scope=perTransaction&transferType=instant&status=active`)
1446+
.reply(200, mockResponse);
1447+
1448+
const response: balancePlatform.TransferLimitListResponse = await balancePlatformService.TransferLimitsBalancePlatformLevelApi.getTransferLimits(balancePlatformId, Scope.PerTransaction, TransferType.Instant, LimitStatus.Active);
1449+
1450+
expect(response.transferLimits.length).toBe(2);
1451+
expect(response.transferLimits[0].id).toBe("TRLI00000000000000000000000001");
1452+
});
1453+
});
1454+
1455+
13261456
});

0 commit comments

Comments
 (0)