From 358d1d111c2a7dfcc13f5881cf7a61625da18711 Mon Sep 17 00:00:00 2001 From: krigga Date: Sun, 5 Nov 2023 18:33:34 +0300 Subject: [PATCH] refactor: tx comparison --- src/test/transaction.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/transaction.ts b/src/test/transaction.ts index 09f1e50..0c801be 100644 --- a/src/test/transaction.ts +++ b/src/test/transaction.ts @@ -129,11 +129,10 @@ export function compareTransaction(tx: FlatTransaction, cmp: FlatTransactionComp export function compareTransactionForTest(subject: any, cmp: FlatTransactionComparable): CompareResult { if (Array.isArray(subject)) { - const arr = (subject as Transaction[]).map(tx => flattenTransaction(tx)) return { - pass: arr.some(ftx => compareTransaction(ftx, cmp)), - posMessage: ((arr: any, cmp: FlatTransactionComparable) => `Expected ${inspect(arr)} to contain a transaction that matches pattern ${inspect(cmp)}`).bind(undefined, arr, cmp), - negMessage: ((arr: any, cmp: FlatTransactionComparable) => `Expected ${inspect(arr)} NOT to contain a transaction that matches pattern ${inspect(cmp)}, but it does`).bind(undefined, arr, cmp), + pass: subject.some(tx => compareTransaction(flattenTransaction(tx), cmp)), + posMessage: ((subj: any[], cmp: FlatTransactionComparable) => `Expected ${inspect(subj.map(tx => flattenTransaction(tx)))} to contain a transaction that matches pattern ${inspect(cmp)}`).bind(undefined, subject, cmp), + negMessage: ((subj: any[], cmp: FlatTransactionComparable) => `Expected ${inspect(subj.map(tx => flattenTransaction(tx)))} NOT to contain a transaction that matches pattern ${inspect(cmp)}, but it does`).bind(undefined, subject, cmp), } } else { try {