Skip to content

Commit

Permalink
refactor: tx comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
krigga committed Nov 5, 2023
1 parent 0138fd5 commit 358d1d1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/test/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 358d1d1

Please sign in to comment.