Skip to content

Commit 41f51c8

Browse files
committed
Fix tests
1 parent 5a85926 commit 41f51c8

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

packages/hardhat-chai-matchers/test/changeEtherBalances.ts

+30-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe("INTEGRATION: changeEtherBalances matcher", function () {
146146
)
147147
).to.be.eventually.rejectedWith(
148148
AssertionError,
149-
"Expected the balance changes of to satisfy the predicate, but they didn't"
149+
"Expected the balance changes of the accounts to satisfy the predicate, but they didn't"
150150
);
151151
});
152152

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

@@ -269,6 +269,34 @@ describe("INTEGRATION: changeEtherBalances matcher", function () {
269269
`Expected the ether balance of ${sender.address} (the 1st address in the list) NOT to change by -200 wei`
270270
);
271271
});
272+
273+
it("arrays have different length", async function () {
274+
expect(() =>
275+
expect(
276+
sender.sendTransaction({
277+
to: receiver.address,
278+
gasPrice: 1,
279+
value: 200,
280+
})
281+
).to.changeEtherBalances([sender], ["-200", 200])
282+
).to.throw(
283+
Error,
284+
"The number of accounts (1) is different than the number of expected balance changes (2)"
285+
);
286+
287+
expect(() =>
288+
expect(
289+
sender.sendTransaction({
290+
to: receiver.address,
291+
gasPrice: 1,
292+
value: 200,
293+
})
294+
).to.changeEtherBalances([sender, receiver], ["-200"])
295+
).to.throw(
296+
Error,
297+
"The number of accounts (2) is different than the number of expected balance changes (1)"
298+
);
299+
});
272300
});
273301

274302
it("shouldn't run the transaction twice", async function () {

packages/hardhat-chai-matchers/test/changeTokenBalance.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe("INTEGRATION: changeTokenBalance and changeTokenBalances matchers", fun
169169
)
170170
).to.be.rejectedWith(
171171
AssertionError,
172-
/Expected the balance of MCK tokens for "0x\w{40}" satisfies the predicate, but it changed by 0 and violated the predicate/
172+
/Expected the balance of MCK tokens for "0x\w{40}" to satisfy the predicate, but it didn't \(change by: 0 wei\)/
173173
);
174174
});
175175

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

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

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

0 commit comments

Comments
 (0)