Skip to content

Commit

Permalink
Add a basic spec file
Browse files Browse the repository at this point in the history
  • Loading branch information
lnagel committed Jan 8, 2025
1 parent 4dd6ad0 commit 9175afd
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions src/app-gocardless/banks/tests/lhv-lhvbee22.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import LhvLhvbee22 from '../lhv-lhvbee22.js';

describe('#normalizeTransaction', () => {
const bookedCardTransaction = {
transactionId: '2025010300000000-1',
bookingDate: '2025-01-03',
valueDate: '2025-01-03',
transactionAmount: {
amount: '-22.99',
currency: 'EUR',
},
creditorName: null,
remittanceInformationUnstructured:
'(..1234) 2025-01-02 09:32 CrustumOU\\Poordi 3\\Tallinn\\10156 ESTEST',
bankTransactionCode: 'PMNT-CCRD-POSD',
internalTransactionId: 'fa000f86afb2cc7678bcff0000000000',
};

it('extracts booked card transaction creditor name', () => {
expect(
LhvLhvbee22.normalizeTransaction(bookedCardTransaction, true)
.creditorName,
).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');
});

it.each([
['regular text', 'Some info'],
['partial card text', 'PIRKUMS xxx'],
['null value', null],
])('normalizes non-card transaction with %s', (_, remittanceInfo) => {
const transaction = {
...bookedCardTransaction,
remittanceInformationUnstructured: remittanceInfo,
};
const normalized = LhvLhvbee22.normalizeTransaction(transaction, true);

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

const pendingCardTransaction = {
transactionId: '2025010300000000-1',
valueDate: '2025-01-03',
transactionAmount: {
amount: '-22.99',
currency: 'EUR',
},
remittanceInformationUnstructured:
'(..1234) 2025-01-02 09:32 CrustumOU\\Poordi 3\\Tallinn\\10156 ESTEST',
};

it('extracts pending card transaction creditor name', () => {
expect(
LhvLhvbee22.normalizeTransaction(pendingCardTransaction, false)
.creditorName,
).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');
});
});

0 comments on commit 9175afd

Please sign in to comment.