From 6c501252ba2858af5751237afd967e832780b956 Mon Sep 17 00:00:00 2001 From: Julian Dominguez-Schatz Date: Sat, 12 Oct 2024 12:51:39 -0400 Subject: [PATCH] Add tests for unexpected behaviour --- .../src/server/accounts/rules.test.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/loot-core/src/server/accounts/rules.test.ts b/packages/loot-core/src/server/accounts/rules.test.ts index 34b1c17c8c1..36ee572e97b 100644 --- a/packages/loot-core/src/server/accounts/rules.test.ts +++ b/packages/loot-core/src/server/accounts/rules.test.ts @@ -675,6 +675,32 @@ describe('Rule', () => { }, ); }); + + test('generate errors on fixed amounts less than total', () => { + expect( + fixedAmountRule.exec({ imported_payee: 'James', amount: 100 }), + ).toMatchObject({ + error: { + difference: -100, + type: 'SplitTransactionError', + version: 1, + }, + subtransactions: [{ amount: 100 }, { amount: 100 }], + }); + }); + + test('generate errors on fixed amounts more than total', () => { + expect( + fixedAmountRule.exec({ imported_payee: 'James', amount: 300 }), + ).toMatchObject({ + error: { + difference: 100, + type: 'SplitTransactionError', + version: 1, + }, + subtransactions: [{ amount: 100 }, { amount: 100 }], + }); + }); }); test('rules are deterministically ranked', () => {