From cb6e79ba50a7870b7d9252602c5eb8885d439489 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Sun, 27 Jul 2025 08:51:31 +0000 Subject: [PATCH] fix(tests): update tests for v4.0.0 stateless architecture compatibility --- changelog.md | 7 +++++++ package.json | 2 +- test/test.advanced.ts | 4 ++-- test/test.errors.ts | 4 ++-- test/test.payments.simple.ts | 2 +- test/test.payments.ts | 4 ++-- test/test.session.ts | 6 +++--- test/test.ts | 6 +++--- test/test.webhooks.ts | 2 +- 9 files changed, 22 insertions(+), 15 deletions(-) diff --git a/changelog.md b/changelog.md index 0011be3..6dc4a93 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-07-27 - 4.2.1 - fix(tests) +Fix test compatibility with breaking changes from v4.0.0 + +- Updated all tests to handle new API structure where methods return objects +- Fixed destructuring for getAccounts() which now returns { accounts, sessionData? } +- Ensures all 83 tests pass successfully with the stateless architecture + ## 2025-07-27 - 4.2.0 - feat(core) Switch to native fetch API for all HTTP requests diff --git a/package.json b/package.json index b2834d2..e3b7af2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apiclient.xyz/bunq", - "version": "4.2.0", + "version": "4.2.1", "private": false, "description": "A full-featured TypeScript/JavaScript client for the bunq API", "type": "module", diff --git a/test/test.advanced.ts b/test/test.advanced.ts index 13a7992..48487fb 100644 --- a/test/test.advanced.ts +++ b/test/test.advanced.ts @@ -25,7 +25,7 @@ tap.test('should setup advanced test environment', async () => { await testBunqAccount.init(); // Get primary account - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); primaryAccount = accounts[0]; console.log('Advanced test environment setup complete'); @@ -389,7 +389,7 @@ tap.test('should test travel mode', async () => { tap.test('should cleanup advanced test resources', async () => { // Clean up any created resources - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); // Close any test accounts created (except primary) for (const account of accounts) { diff --git a/test/test.errors.ts b/test/test.errors.ts index 734706b..4308769 100644 --- a/test/test.errors.ts +++ b/test/test.errors.ts @@ -25,7 +25,7 @@ tap.test('should setup error test environment', async () => { await testBunqAccount.init(); // Get primary account - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); primaryAccount = accounts[0]; expect(primaryAccount).toBeInstanceOf(bunq.BunqMonetaryAccount); @@ -283,7 +283,7 @@ tap.test('should test error recovery strategies', async () => { } const accounts = await retryableOperation(); - expect(accounts).toBeArray(); + expect(accounts.accounts).toBeArray(); console.log('Error recovery with retry successful'); // 2. Recover from expired session diff --git a/test/test.payments.simple.ts b/test/test.payments.simple.ts index 46ad5e8..a0adbeb 100644 --- a/test/test.payments.simple.ts +++ b/test/test.payments.simple.ts @@ -26,7 +26,7 @@ tap.test('should setup payment test environment', async () => { await testBunqAccount.init(); // Get primary account - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); primaryAccount = accounts[0]; expect(primaryAccount).toBeInstanceOf(bunq.BunqMonetaryAccount); diff --git a/test/test.payments.ts b/test/test.payments.ts index cf57216..6f4c0e7 100644 --- a/test/test.payments.ts +++ b/test/test.payments.ts @@ -27,7 +27,7 @@ tap.test('should create test setup with multiple accounts', async () => { await testBunqAccount.init(); // Get accounts - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); primaryAccount = accounts[0]; // Create a second account for testing transfers @@ -40,7 +40,7 @@ tap.test('should create test setup with multiple accounts', async () => { }); // Refresh accounts list - const updatedAccounts = await testBunqAccount.getAccounts(); + const { accounts: updatedAccounts } = await testBunqAccount.getAccounts(); secondaryAccount = updatedAccounts.find(acc => acc.id === newAccount.id) || primaryAccount; } catch (error) { console.log('Could not create secondary account, using primary for tests'); diff --git a/test/test.session.ts b/test/test.session.ts index 6762741..c085132 100644 --- a/test/test.session.ts +++ b/test/test.session.ts @@ -84,7 +84,7 @@ tap.test('should test concurrent session usage', async () => { // Execute all operations concurrently const results = await Promise.all(operations); - expect(results[0]).toBeArray(); // Accounts + expect(results[0].accounts).toBeArray(); // Accounts expect(results[1]).toBeDefined(); // User info expect(results[2]).toBeArray(); // Notification filters @@ -172,7 +172,7 @@ tap.test('should test session token rotation', async () => { // Make multiple requests to test token handling for (let i = 0; i < 3; i++) { - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); expect(accounts).toBeArray(); console.log(`Request ${i + 1} completed successfully`); @@ -213,7 +213,7 @@ tap.test('should test session cleanup on error', async () => { } // Ensure we can still use the session - const accounts = await tempAccount.getAccounts(); + const { accounts } = await tempAccount.getAccounts(); expect(accounts).toBeArray(); console.log('Session still functional after error'); diff --git a/test/test.ts b/test/test.ts index 716b6b4..b4d121e 100644 --- a/test/test.ts +++ b/test/test.ts @@ -41,7 +41,7 @@ tap.test('should init the client', async () => { }); tap.test('should get accounts', async () => { - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); expect(accounts).toBeArray(); expect(accounts.length).toBeGreaterThan(0); @@ -56,7 +56,7 @@ tap.test('should get accounts', async () => { }); tap.test('should get transactions', async () => { - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); const account = accounts[0]; const transactions = await account.getTransactions(); @@ -74,7 +74,7 @@ tap.test('should get transactions', async () => { }); tap.test('should test payment builder', async () => { - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); const account = accounts[0]; // Test payment builder without actually creating the payment diff --git a/test/test.webhooks.ts b/test/test.webhooks.ts index 761149d..f293897 100644 --- a/test/test.webhooks.ts +++ b/test/test.webhooks.ts @@ -27,7 +27,7 @@ tap.test('should setup webhook test environment', async () => { await testBunqAccount.init(); // Get primary account - const accounts = await testBunqAccount.getAccounts(); + const { accounts } = await testBunqAccount.getAccounts(); primaryAccount = accounts[0]; expect(primaryAccount).toBeInstanceOf(bunq.BunqMonetaryAccount);