From 4b0f0121f915396f98e311c2006c5af8599a4f0b Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Wed, 10 Jan 2024 17:52:23 +0000 Subject: [PATCH] Fix unit tests --- packages/loot-core/src/shared/transactions.test.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/loot-core/src/shared/transactions.test.ts b/packages/loot-core/src/shared/transactions.test.ts index 1de55fa1e64..a256f9c6479 100644 --- a/packages/loot-core/src/shared/transactions.test.ts +++ b/packages/loot-core/src/shared/transactions.test.ts @@ -61,7 +61,7 @@ describe('Transactions', () => { expect(diff).toEqual({ added: [], deleted: [], - updated: [{ id: 't1', amount: 5000 }], + updated: [expect.objectContaining({ id: 't1', amount: 5000 })], }); expect(data.map(t => ({ id: t.id, amount: t.amount })).sort()).toEqual([ { id: expect.any(String), amount: 5000 }, @@ -71,17 +71,12 @@ describe('Transactions', () => { }); test('updating does nothing if value not changed', () => { + const updatedTransaction = makeTransaction({ id: 't1', amount: 5000 }); const transactions = [ - makeTransaction({ id: 't1', amount: 5000 }), + updatedTransaction, makeTransaction({ amount: 3000 }), ]; - const { data, diff } = updateTransaction( - transactions, - makeTransaction({ - id: 't1', - amount: 5000, - }), - ); + const { data, diff } = updateTransaction(transactions, updatedTransaction); expect(diff).toEqual({ added: [], deleted: [], updated: [] }); expect(data.map(t => ({ id: t.id, amount: t.amount })).sort()).toEqual([ { id: expect.any(String), amount: 5000 },