From 1c038eae49dce1748b2378f714adc9d865fcd288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis?= Date: Tue, 5 Nov 2024 11:32:02 +0200 Subject: [PATCH] Reduce duplication in swedbank-habalv22.spec.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../banks/tests/swedbank-habalv22.spec.js | 46 ++++--------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/src/app-gocardless/banks/tests/swedbank-habalv22.spec.js b/src/app-gocardless/banks/tests/swedbank-habalv22.spec.js index 43cd492b9..02a163238 100644 --- a/src/app-gocardless/banks/tests/swedbank-habalv22.spec.js +++ b/src/app-gocardless/banks/tests/swedbank-habalv22.spec.js @@ -26,44 +26,18 @@ describe('#normalizeTransaction', () => { ).toEqual('2024-10-28'); }); - it('normalizes non-card transactions as usual', () => { - const nonCardTransaction1 = { + it.each([ + ['regular text', 'Some info'], + ['partial card text', 'PIRKUMS xxx'], + ['null value', null], + ])('normalizes non-card transaction with %s', (_, remittanceInfo) => { + const transaction = { ...cardTransaction, - remittanceInformationUnstructured: 'Some info', + remittanceInformationUnstructured: remittanceInfo, }; - expect( - SwedbankHabaLV22.normalizeTransaction(nonCardTransaction1, true) - .bookingDate, - ).toEqual('2024-10-29'); - - expect( - SwedbankHabaLV22.normalizeTransaction(nonCardTransaction1, true).date, - ).toEqual('2024-10-29'); - - const nonCardTransaction2 = { - ...cardTransaction, - remittanceInformationUnstructured: 'PIRKUMS xxx', - }; - expect( - SwedbankHabaLV22.normalizeTransaction(nonCardTransaction2, true) - .bookingDate, - ).toEqual('2024-10-29'); + const normalized = SwedbankHabaLV22.normalizeTransaction(transaction, true); - expect( - SwedbankHabaLV22.normalizeTransaction(nonCardTransaction2, true).date, - ).toEqual('2024-10-29'); - - const nonCardTransaction3 = { - ...cardTransaction, - remittanceInformationUnstructured: null, - }; - expect( - SwedbankHabaLV22.normalizeTransaction(nonCardTransaction3, true) - .bookingDate, - ).toEqual('2024-10-29'); - - expect( - SwedbankHabaLV22.normalizeTransaction(nonCardTransaction3, true).date, - ).toEqual('2024-10-29'); + expect(normalized.bookingDate).toEqual('2024-10-29'); + expect(normalized.date).toEqual('2024-10-29'); }); });