Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Jan 29, 2025
1 parent 392ff90 commit a764acf
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 78 deletions.
1 change: 1 addition & 0 deletions src/app-gocardless/banks/belfius_gkccbebb.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default {
// They will set an internalTransactionId which is unique
normalizeTransaction(transaction, booked) {
transaction.transactionId = transaction.internalTransactionId;

return Fallback.normalizeTransaction(transaction, booked);
},
};
5 changes: 3 additions & 2 deletions src/app-gocardless/banks/integration-bank.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
const trans = editedTransaction ?? transaction;

const date =
editedTransaction.date ||
trans.date ||
transaction.bookingDate ||
transaction.bookingDateTime ||
transaction.valueDate ||
Expand All @@ -61,8 +61,9 @@ export default {
}

const notes =
trans.notes ??
trans.remittanceInformationUnstructured ??
trans.remittanceInformationUnstructuredArray.join(' ');
trans.remittanceInformationUnstructuredArray?.join(' ');

transaction.remittanceInformationUnstructuredArrayString =
transaction.remittanceInformationUnstructuredArray?.join(',');
Expand Down
2 changes: 1 addition & 1 deletion src/app-gocardless/banks/lhv-lhvbee22.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {
if (cardTxMatch) {
const extractedDate = d.parse(cardTxMatch[2], 'yyyy-MM-dd', new Date());

editedTrans.creditorName = cardTxMatch[4].split('\\')[0].trim();
editedTrans.payeeName = cardTxMatch[4].split('\\')[0].trim();

if (booked && d.isValid(extractedDate)) {
editedTrans.date = d.format(extractedDate, 'yyyy-MM-dd');
Expand Down
2 changes: 1 addition & 1 deletion src/app-gocardless/banks/nbg_ethngraaxxx.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
!transaction.transactionId &&
transaction.remittanceInformationUnstructured.startsWith('ΑΓΟΡΑ ')
) {
editedTrans.transactionAmount = {
transaction.transactionAmount = {
amount: '-' + transaction.transactionAmount.amount,
currency: transaction.transactionAmount.currency,
};
Expand Down
8 changes: 3 additions & 5 deletions src/app-gocardless/banks/tests/abanca_caglesmm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ describe('Abanca', () => {
internalTransactionId: 'D202301180000003',
transactionAmount: mockTransactionAmount,
remittanceInformationStructured: 'some-creditor-name',
date: new Date().toISOString(),
};
const normalizedTransaction = Abanca.normalizeTransaction(
transaction,
true,
);
expect(normalizedTransaction.creditorName).toEqual(
transaction.remittanceInformationStructured,
);
expect(normalizedTransaction.debtorName).toEqual(
transaction.remittanceInformationStructured,
expect(normalizedTransaction.payeeName).toEqual(

Check failure on line 18 in src/app-gocardless/banks/tests/abanca_caglesmm.spec.js

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎········'Some-Creditor-Name',⏎······` with `'Some-Creditor-Name'`
'Some-Creditor-Name',
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/app-gocardless/banks/tests/abnamro_abnanl2a.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('AbnamroAbnanl2a', () => {
false,
);

expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
expect(normalizedTransaction.notes).toEqual(
'BEA, Betaalpas, My Payee Name,PAS123, NR:123A4B, 09.12.23/15:43, CITY',
);
expect(normalizedTransaction.payeeName).toEqual('My Payee Name');
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('AbnamroAbnanl2a', () => {
false,
);

expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
expect(normalizedTransaction.notes).toEqual(
'BEA, Google Pay, CCV*Other payee name,PAS123, NR:123A4B, 09.12.23/15:43, CITY',
);
expect(normalizedTransaction.payeeName).toEqual('Other Payee Name');
Expand Down
8 changes: 3 additions & 5 deletions src/app-gocardless/banks/tests/bancsabadell_bsabesbbb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ describe('BancSabadell', () => {
transaction,
true,
);
expect(normalizedTransaction.creditorName).toEqual(
'some-creditor-name',
expect(normalizedTransaction.payeeName).toEqual(

Check failure on line 18 in src/app-gocardless/banks/tests/bancsabadell_bsabesbbb.spec.js

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎··········'Some-Creditor-Name',⏎········` with `'Some-Creditor-Name'`
'Some-Creditor-Name',
);
expect(normalizedTransaction.debtorName).toEqual(null);
});

it('creditor role - amount > 0', () => {
Expand All @@ -33,8 +32,7 @@ describe('BancSabadell', () => {
transaction,
true,
);
expect(normalizedTransaction.debtorName).toEqual('some-debtor-name');
expect(normalizedTransaction.creditorName).toEqual(null);
expect(normalizedTransaction.payeeName).toEqual('Some-Debtor-Name');
});
});

Expand Down
1 change: 1 addition & 0 deletions src/app-gocardless/banks/tests/belfius_gkccbebb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('Belfius', () => {
transactionId: 'non-unique-id',
internalTransactionId: 'D202301180000003',
transactionAmount: mockTransactionAmount,
date: new Date().toISOString(),
};
const normalizedTransaction = Belfius.normalizeTransaction(
transaction,
Expand Down
2 changes: 2 additions & 0 deletions src/app-gocardless/banks/tests/cbc_cregbebb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('cbc_cregbebb', () => {
remittanceInformationUnstructured:
'ONKART FR Viry Paiement Maestro par Carte de débit CBC 05-09-2024 à 15.43 heures 6703 19XX XXXX X201 5 JOHN DOE',
transactionAmount: { amount: '-45.00', currency: 'EUR' },
date: new Date().toISOString(),
};
const normalizedTransaction = CBCcregbebb.normalizeTransaction(
transaction,
Expand All @@ -21,6 +22,7 @@ describe('cbc_cregbebb', () => {
remittanceInformationUnstructured:
'ONKART FR Viry Paiement Maestro par Carte de débit CBC 05-09-2024 à 15.43 heures 6703 19XX XXXX X201 5 JOHN DOE',
transactionAmount: { amount: '10.99', currency: 'EUR' },
date: new Date().toISOString(),
};
const normalizedTransaction = CBCcregbebb.normalizeTransaction(
transaction,
Expand Down
6 changes: 3 additions & 3 deletions src/app-gocardless/banks/tests/commerzbank_cobadeff.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('CommerzbankCobadeff', () => {
transaction,
false,
);
expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
expect(normalizedTransaction.notes).toEqual(
'2024-12-19T15:34:31 KFN 1 AB 1234, Kartenzahlung',
);
});
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('CommerzbankCobadeff', () => {
transaction,
false,
);
expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
expect(normalizedTransaction.notes).toEqual(
'901234567890/. Long description tha t gets cut and is very long, did I mention it is long, End-to-End-Ref.: 901234567890, Mandatsref: ABC123DEF456, Gläubiger-ID: AB12CDE0000000000000000012, SEPA-BASISLASTSCHRIFT wiederholend',
);
});
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('CommerzbankCobadeff', () => {
transaction,
false,
);
expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
expect(normalizedTransaction.notes).toEqual(
'CREDITOR00BIC CREDITOR000IBAN DESCRIPTION, Dauerauftrag',
);
});
Expand Down
20 changes: 9 additions & 11 deletions src/app-gocardless/banks/tests/fortuneo_ftnofrp1xxx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,12 @@ describe('Fortuneo', () => {
true,
);

expect(normalizedCreditorTransaction.creditorName).toBeDefined();
expect(normalizedCreditorTransaction.debtorName).toBeNull();
expect(normalizedCreditorTransaction.payeeName).toBeDefined();
expect(
parseFloat(normalizedCreditorTransaction.transactionAmount.amount),
).toBeLessThan(0);

expect(normalizedDebtorTransaction.debtorName).toBeDefined();
expect(normalizedDebtorTransaction.creditorName).toBeNull();
expect(normalizedDebtorTransaction.payeeName).toBeDefined();
expect(
parseFloat(normalizedDebtorTransaction.transactionAmount.amount),
).toBeGreaterThan(0);
Expand All @@ -160,23 +158,23 @@ describe('Fortuneo', () => {
true,
);

expect(normalizedTransaction.creditorName).toBe('ONG');
expect(normalizedTransaction.payeeName).toBe('Ong');

const transaction2 = transactionsRaw[2];
const normalizedTransaction2 = Fortuneo.normalizeTransaction(
transaction2,
true,
);

expect(normalizedTransaction2.creditorName).toBe('XXXYYYYZZZ');
expect(normalizedTransaction2.payeeName).toBe('Xxxyyyyzzz');

const transaction3 = transactionsRaw[3];
const normalizedTransaction3 = Fortuneo.normalizeTransaction(
transaction3,
true,
);

expect(normalizedTransaction3.creditorName).toBe(
expect(normalizedTransaction3.payeeName).toBe(

Check failure on line 177 in src/app-gocardless/banks/tests/fortuneo_ftnofrp1xxx.spec.js

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎········'Google·Payment·I·Dublin',⏎······` with `'Google·Payment·I·Dublin'`
'Google Payment I Dublin',
);

Expand All @@ -186,24 +184,24 @@ describe('Fortuneo', () => {
true,
);

expect(normalizedTransaction4.creditorName).toBe('SPORT MARKET');
expect(normalizedTransaction4.payeeName).toBe('Sport Market');

const transaction5 = transactionsRaw[5];
const normalizedTransaction5 = Fortuneo.normalizeTransaction(
transaction5,
true,
);

expect(normalizedTransaction5.debtorName).toBe('WEEZEVENT SOMEPLACE');
expect(normalizedTransaction5.payeeName).toBe('Weezevent Someplace');

const transaction7 = transactionsRaw[7];
const normalizedTransaction7 = Fortuneo.normalizeTransaction(
transaction7,
true,
);

expect(normalizedTransaction7.creditorName).toBe(
'Leclerc XXXX Leclerc XXXX 44321IXCRT211141232',
expect(normalizedTransaction7.payeeName).toBe(
'Leclerc Xxxx Leclerc Xxxx 44321ixcrt211141232',
);
});
});
Expand Down
2 changes: 2 additions & 0 deletions src/app-gocardless/banks/tests/kbc_kredbebb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('kbc_kredbebb', () => {
remittanceInformationUnstructured:
'CARREFOUR ST GIL BE1060 BRUXELLES Betaling met Google Pay via Debit Mastercard 28-08-2024 om 19.15 uur 5127 04XX XXXX 1637 5853 98XX XXXX 2266 JOHN SMITH',
transactionAmount: { amount: '-10.99', currency: 'EUR' },
date: new Date().toISOString(),
};
const normalizedTransaction = KBCkredbebb.normalizeTransaction(
transaction,
Expand All @@ -23,6 +24,7 @@ describe('kbc_kredbebb', () => {
remittanceInformationUnstructured:
'CARREFOUR ST GIL BE1060 BRUXELLES Betaling met Google Pay via Debit Mastercard 28-08-2024 om 19.15 uur 5127 04XX XXXX 1637 5853 98XX XXXX 2266 JOHN SMITH',
transactionAmount: { amount: '10.99', currency: 'EUR' },
date: new Date().toISOString(),
};
const normalizedTransaction = KBCkredbebb.normalizeTransaction(
transaction,
Expand Down
14 changes: 2 additions & 12 deletions src/app-gocardless/banks/tests/lhv-lhvbee22.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ describe('#normalizeTransaction', () => {
it('extracts booked card transaction creditor name', () => {
expect(
LhvLhvbee22.normalizeTransaction(bookedCardTransaction, true)

Check failure on line 21 in src/app-gocardless/banks/tests/lhv-lhvbee22.spec.js

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎········`
.creditorName,
.payeeName,
).toEqual('CrustumOU');
});

it('extracts booked card transaction date', () => {
expect(
LhvLhvbee22.normalizeTransaction(bookedCardTransaction, true).bookingDate,
).toEqual('2025-01-02');

expect(
LhvLhvbee22.normalizeTransaction(bookedCardTransaction, true).date,
).toEqual('2025-01-02');
Expand All @@ -45,7 +41,6 @@ describe('#normalizeTransaction', () => {
};
const normalized = LhvLhvbee22.normalizeTransaction(transaction, true);

expect(normalized.bookingDate).toEqual('2025-01-03');
expect(normalized.date).toEqual('2025-01-03');
});

Expand All @@ -63,16 +58,11 @@ describe('#normalizeTransaction', () => {
it('extracts pending card transaction creditor name', () => {
expect(
LhvLhvbee22.normalizeTransaction(pendingCardTransaction, false)

Check failure on line 60 in src/app-gocardless/banks/tests/lhv-lhvbee22.spec.js

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎········`
.creditorName,
.payeeName,
).toEqual('CrustumOU');
});

it('extracts pending card transaction date', () => {
expect(
LhvLhvbee22.normalizeTransaction(pendingCardTransaction, false)
.bookingDate,
).toEqual(undefined);

expect(
LhvLhvbee22.normalizeTransaction(pendingCardTransaction, false).date,
).toEqual('2025-01-03');
Expand Down
4 changes: 2 additions & 2 deletions src/app-gocardless/banks/tests/revolut_revolt21.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('RevolutRevolt21', () => {
true,
);

expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
expect(normalizedTransaction.notes).toEqual(

Check failure on line 20 in src/app-gocardless/banks/tests/revolut_revolt21.spec.js

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎········'Bizum·description',⏎······` with `'Bizum·description'`
'Bizum description',
);
});
Expand All @@ -39,7 +39,7 @@ describe('RevolutRevolt21', () => {
);

expect(normalizedTransaction.payeeName).toEqual('DEBTOR NAME');
expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
expect(normalizedTransaction.notes).toEqual(

Check failure on line 42 in src/app-gocardless/banks/tests/revolut_revolt21.spec.js

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎······'Bizum·description',⏎····` with `'Bizum·description'`
'Bizum description',
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('SpkMarburgBiedenkopfHeladef1mar', () => {

expect(
SpkMarburgBiedenkopfHeladef1mar.normalizeTransaction(transaction, true)
.remittanceInformationUnstructured,
.notes,
).toEqual('AUTORISATION 28.12. 18:30');
});

Expand All @@ -172,7 +172,7 @@ describe('SpkMarburgBiedenkopfHeladef1mar', () => {

expect(
SpkMarburgBiedenkopfHeladef1mar.normalizeTransaction(transaction, true)
.remittanceInformationUnstructured,
.notes,
).toEqual('Entgeltabrechnung siehe Anlage');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ describe('ssk_dusseldorf_dussdeddxxx', () => {
SskDusseldorfDussdeddxxx.normalizeTransaction(
bookedTransactionOne,
true,
).remittanceInformationUnstructured,
).notes,
).toEqual('unstructured information some additional information');

expect(
SskDusseldorfDussdeddxxx.normalizeTransaction(
bookedTransactionTwo,
true,
).remittanceInformationUnstructured,
).notes,
).toEqual('structured information some additional information');
});

Expand Down
9 changes: 2 additions & 7 deletions src/app-gocardless/banks/tests/swedbank_habalv22.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ describe('#normalizeTransaction', () => {
};

it('extracts card transaction date', () => {
expect(
SwedbankHabaLV22.normalizeTransaction(bookedCardTransaction, true)
.bookingDate,
).toEqual('2024-10-28');

expect(
SwedbankHabaLV22.normalizeTransaction(bookedCardTransaction, true).date,
).toEqual('2024-10-28');
Expand Down Expand Up @@ -56,7 +51,7 @@ describe('#normalizeTransaction', () => {
it('extracts pending card transaction creditor name', () => {
expect(
SwedbankHabaLV22.normalizeTransaction(pendingCardTransaction, false)
.creditorName,
).toEqual('SOME CREDITOR NAME');
.payeeName,
).toEqual('Some Creditor Name');
});
});
Loading

0 comments on commit a764acf

Please sign in to comment.