Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schaable committed May 15, 2024
1 parent 5a85926 commit 41f51c8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
32 changes: 30 additions & 2 deletions packages/hardhat-chai-matchers/test/changeEtherBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe("INTEGRATION: changeEtherBalances matcher", function () {
)
).to.be.eventually.rejectedWith(
AssertionError,
"Expected the balance changes of to satisfy the predicate, but they didn't"
"Expected the balance changes of the accounts to satisfy the predicate, but they didn't"
);
});

Expand All @@ -168,7 +168,7 @@ describe("INTEGRATION: changeEtherBalances matcher", function () {
)
).to.be.eventually.rejectedWith(
AssertionError,
"Expected the balance changes of to NOT satisfy the predicate, but they did"
"Expected the balance changes of the accounts to NOT satisfy the predicate, but they did"
);
});

Expand Down Expand Up @@ -269,6 +269,34 @@ describe("INTEGRATION: changeEtherBalances matcher", function () {
`Expected the ether balance of ${sender.address} (the 1st address in the list) NOT to change by -200 wei`
);
});

it("arrays have different length", async function () {
expect(() =>
expect(
sender.sendTransaction({
to: receiver.address,
gasPrice: 1,
value: 200,
})
).to.changeEtherBalances([sender], ["-200", 200])
).to.throw(
Error,
"The number of accounts (1) is different than the number of expected balance changes (2)"
);

expect(() =>
expect(
sender.sendTransaction({
to: receiver.address,
gasPrice: 1,
value: 200,
})
).to.changeEtherBalances([sender, receiver], ["-200"])
).to.throw(
Error,
"The number of accounts (2) is different than the number of expected balance changes (1)"
);
});
});

it("shouldn't run the transaction twice", async function () {
Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat-chai-matchers/test/changeTokenBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe("INTEGRATION: changeTokenBalance and changeTokenBalances matchers", fun
)
).to.be.rejectedWith(
AssertionError,
/Expected the balance of MCK tokens for "0x\w{40}" satisfies the predicate, but it changed by 0 and violated the predicate/
/Expected the balance of MCK tokens for "0x\w{40}" to satisfy the predicate, but it didn't \(change by: 0 wei\)/
);
});

Expand All @@ -195,7 +195,7 @@ describe("INTEGRATION: changeTokenBalance and changeTokenBalances matchers", fun
)
).to.be.rejectedWith(
AssertionError,
/Expected the balance of MCK tokens for "0x\w{40}" NOT satisfies the predicate, but it did/
/Expected the balance of MCK tokens for "0x\w{40}" to NOT satisfy the predicate, but it did \(change by: 0 wei\)/
);
});

Expand Down Expand Up @@ -398,7 +398,7 @@ describe("INTEGRATION: changeTokenBalance and changeTokenBalances matchers", fun
)
).to.be.rejectedWith(
AssertionError,
/Expected the balance of MCK tokens for "0x\w{40}" satisfies the predicate, but it changed by 50 and violated the predicate/
/Expected the balance of MCK tokens for "0x\w{40}" to satisfy the predicate, but it didn't \(change by: 50 wei\)/
);
});

Expand All @@ -424,7 +424,7 @@ describe("INTEGRATION: changeTokenBalance and changeTokenBalances matchers", fun
)
).to.be.rejectedWith(
AssertionError,
/Expected the balance of MCK tokens for "0x\w{40}" NOT satisfies the predicate, but it did/
/Expected the balance of MCK tokens for "0x\w{40}" to NOT satisfy the predicate, but it did \(change by: 50 wei\)/
);
});

Expand Down

0 comments on commit 41f51c8

Please sign in to comment.