From 63c6d4f7d83af9431fd26dbac0262043b5e77968 Mon Sep 17 00:00:00 2001 From: Leonardo Kagohara Date: Mon, 17 Mar 2025 22:15:53 -0300 Subject: [PATCH] Fix corporate card and holder resources --- CHANGELOG.md | 3 +++ sdk/corporateHolder/log/log.js | 2 +- tests/testCorporateCardLog.js | 14 +++++++------- tests/testCorporateHolder.js | 4 ++-- tests/testCorporatePurchase.js | 2 +- tests/testCorporateTransaction.js | 2 +- tests/testCorporateWithdrawal.js | 2 +- tests/testcorporateHolderLog.js | 16 ++++++++-------- tests/testcorporatePurchaseLog.js | 2 +- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 620d4738..8f61bf79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ Given a version number MAJOR.MINOR.PATCH, increment: ## [Unreleased] +### Fixed +- corporateCard tests +- corporateHolder Log getId method and tests ## [2.30.0] - 2025-03-13 ### Added diff --git a/sdk/corporateHolder/log/log.js b/sdk/corporateHolder/log/log.js index 6f6f0016..b7c891af 100644 --- a/sdk/corporateHolder/log/log.js +++ b/sdk/corporateHolder/log/log.js @@ -49,7 +49,7 @@ exports.get = async function (id, {user} = {}) { * */ - return rest.deleteId(resource, id, user); + return rest.getId(resource, id, user); } exports.query = async function ({limit, after, before, types, holderIds, ids, user} = {}) { diff --git a/tests/testCorporateCardLog.js b/tests/testCorporateCardLog.js index fd65dec5..acedda1a 100644 --- a/tests/testCorporateCardLog.js +++ b/tests/testCorporateCardLog.js @@ -26,10 +26,10 @@ describe('TestCorporateCardLogPage', function () { describe('TestCorporateCardLogGet', function(){ this.timeout(10000); it('test_success', async () => { - let cards = await starkbank.corporateCard.log.query({"limit": 1}) - for await (let card of cards) { - card = await starkbank.corporateCard.log.get(card.id) - assert(typeof card.id == typeof 'String') + let cardLogs = await starkbank.corporateCard.log.query({"limit": 1}) + for await (let log of cardLogs) { + log = await starkbank.corporateCard.log.get(log.id) + assert(typeof log.id == typeof 'String') } }); }); @@ -38,9 +38,9 @@ describe('TestCorporateCardLogQuery', function(){ this.timeout(10000); it('test_success', async () => { let i = 0; - const cards = await starkbank.corporateCard.log.query({limit: 5}); - for await (let card of cards) { - assert(typeof card.id == 'string'); + const cardLogs = await starkbank.corporateCard.log.query({limit: 5}); + for await (let log of cardLogs) { + assert(typeof log.id == 'string'); i += 1; } assert(i === 5); diff --git a/tests/testCorporateHolder.js b/tests/testCorporateHolder.js index 398c65c0..be55772c 100644 --- a/tests/testCorporateHolder.js +++ b/tests/testCorporateHolder.js @@ -12,7 +12,7 @@ describe('TestCorporateHolderCreate', function(){ new starkbank.CorporateHolder({ name: "Test - " + randomInt.randomInt(100000, 1000000), permissions: [ - new starkbank.corporateHolder.Permission({'ownerId': '6253551860842496', 'ownerType': 'project'}) + new starkbank.corporateHolder.Permission({'ownerId': starkbank.user.id, 'ownerType': 'project'}) ] }) ] @@ -46,7 +46,7 @@ describe('TestCorporateHolderGet', function () { let purchases = await starkbank.corporatePurchase.query({ limit: 1 }); for await (let purchase of purchases) { assert(typeof purchase.id == typeof 'string'); - brcode = await starkbank.corporatePurchase.get(purchase.id); + purchase = await starkbank.corporatePurchase.get(purchase.id); assert(typeof purchase.id == typeof 'string'); } }); diff --git a/tests/testCorporatePurchase.js b/tests/testCorporatePurchase.js index 850d1b81..c6ecda6c 100644 --- a/tests/testCorporatePurchase.js +++ b/tests/testCorporatePurchase.js @@ -22,7 +22,7 @@ describe('TestCorporatePurchaseGet', function () { let purchases = await starkbank.corporatePurchase.query({ limit: 1 }); for await (let purchase of purchases) { assert(typeof purchase.id == typeof 'string'); - brcode = await starkbank.corporatePurchase.get(purchase.id); + purchase = await starkbank.corporatePurchase.get(purchase.id); assert(typeof purchase.id == typeof 'string'); } }); diff --git a/tests/testCorporateTransaction.js b/tests/testCorporateTransaction.js index 2b5f8696..be5e5eea 100644 --- a/tests/testCorporateTransaction.js +++ b/tests/testCorporateTransaction.js @@ -22,7 +22,7 @@ describe('TestCorporateTransactionGet', function () { let transactions = await starkbank.corporateTransaction.query({ limit: 1 }); for await (let transaction of transactions) { assert(typeof transaction.id == typeof 'string'); - brcode = await starkbank.corporateTransaction.get(transaction.id); + transaction = await starkbank.corporateTransaction.get(transaction.id); assert(typeof transaction.id == typeof 'string'); } }); diff --git a/tests/testCorporateWithdrawal.js b/tests/testCorporateWithdrawal.js index 9db17444..4ce46756 100644 --- a/tests/testCorporateWithdrawal.js +++ b/tests/testCorporateWithdrawal.js @@ -56,7 +56,7 @@ describe('TestCorporateTransactionGet', function () { let withdrawals = await starkbank.corporateWithdrawal.query({ limit: 1 }); for await (let withdrawal of withdrawals) { assert(typeof withdrawal.id == typeof 'string'); - brcode = await starkbank.corporateWithdrawal.get(withdrawal.id); + purchase = await starkbank.corporateWithdrawal.get(withdrawal.id); assert(typeof withdrawal.id == typeof 'string'); } }); diff --git a/tests/testcorporateHolderLog.js b/tests/testcorporateHolderLog.js index 4d59a037..981cf75b 100644 --- a/tests/testcorporateHolderLog.js +++ b/tests/testcorporateHolderLog.js @@ -7,9 +7,9 @@ describe('TestCorporateHolderQuery', function(){ this.timeout(10000); it('test_success', async () => { let i = 0; - const holders = await starkbank.corporateHolder.log.query({limit: 5}); - for await (let holder of holders) { - assert(typeof holder.id == 'string'); + const holderLogs = await starkbank.corporateHolder.log.query({limit: 5}); + for await (let log of holderLogs) { + assert(typeof log.id == 'string'); i += 1; } assert(i === 5); @@ -19,11 +19,11 @@ describe('TestCorporateHolderQuery', function(){ describe('TestCorporateHolderGet', function () { this.timeout(10000); it('test_success', async () => { - let purchases = await starkbank.corporatePurchase.log.query({limit: 1}); - for await (let purchase of purchases) { - assert(typeof purchase.id == typeof 'string'); - brcode = await starkbank.corporatePurchase.log.get(purchase.id); - assert(typeof purchase.id == typeof 'string'); + let purchaseLogs = await starkbank.corporatePurchase.log.query({limit: 1}); + for await (let log of purchaseLogs) { + assert(typeof log.id == typeof 'string'); + log = await starkbank.corporatePurchase.log.get(log.id); + assert(typeof log.id == typeof 'string'); } }); }); diff --git a/tests/testcorporatePurchaseLog.js b/tests/testcorporatePurchaseLog.js index dac16649..1ce528fa 100644 --- a/tests/testcorporatePurchaseLog.js +++ b/tests/testcorporatePurchaseLog.js @@ -22,7 +22,7 @@ describe('TestCorporatePurchaseLogGet', function () { let purchases = await starkbank.corporatePurchase.log.query({ limit: 1 }); for await (let purchase of purchases) { assert(typeof purchase.id == typeof 'string'); - brcode = await starkbank.corporatePurchase.log.get(purchase.id); + purchase = await starkbank.corporatePurchase.log.get(purchase.id); assert(typeof purchase.id == typeof 'string'); } });