fix(tests): update tests for v4.0.0 stateless architecture compatibility
This commit is contained in:
@@ -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
|
||||
|
||||
|
@@ -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",
|
||||
|
@@ -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) {
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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');
|
||||
|
@@ -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');
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user