Skip to content

Commit

Permalink
Add test for non-matched addressable arg
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Dec 26, 2023
1 parent dff8302 commit 3eb226e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/hardhat-chai-matchers/test/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ describe(".to.emit (contract events)", () => {
describe("with an address argument", function () {
const addressable = ethers.Wallet.createRandom();
const { address } = addressable;
const { address: otherAddress } = ethers.Wallet.createRandom();
const otherAddressable = ethers.Wallet.createRandom();
const { address: otherAddress } = otherAddressable;

it("Should match the argument", async function () {
await expect(contract.emitAddress(addressable))
Expand All @@ -162,7 +163,18 @@ describe(".to.emit (contract events)", () => {
.withArgs(addressable);
});

it("Should fail when the input argument doesn't match the event argument", async function () {
it("Should fail when the input argument doesn't match the addressable event argument", async function () {
await expect(
expect(contract.emitAddress(addressable))
.to.emit(contract, "WithAddressArg")
.withArgs(otherAddressable)
).to.be.eventually.rejectedWith(
AssertionError,
`expected '${address}' to equal '${otherAddress}'`
);
});

it("Should fail when the input argument doesn't match the address event argument", async function () {
await expect(
expect(contract.emitAddress(addressable))
.to.emit(contract, "WithAddressArg")
Expand Down

0 comments on commit 3eb226e

Please sign in to comment.