-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expect(...).to.be.called #229
Comments
It is important to not interfere with https://www.npmjs.com/package/sinon-chai |
This is what we came up with @Jozwiaczek expect(contract).to.be.ethCalled
expect([contract, 'function']).to.be.ethCalled
expect([contract, 'function']).to.be.ethCalledWith(arg1, arg2) |
Originally proposed syntax is not possible to implement. 1)
expect('functionName').to.be.calledOn(contract)
expect('functionName').to.be.calledOn(contract).withArgs(args)
2)
expect(contract).to.be.ethCalled
expect([contract, 'function']).to.be.ethCalled
expect([contract, 'function']).to.be.ethCalledWith(arg1, arg2)
3)
expect(contract).to.be.calledWith('functionName')
expect(contract).to.be.calledWith('functionName', ...args)
expect(contract).to.be.calledWith('functionName').withArgs(args) |
The results are: |
Voted Option 1) still is impossible to implement (name collision with 1)
expect('functionName').to.be
.calledOnContract(contract)
expect('functionName').not.to.be.calledOnContract(contract)
expect('functionName').to.be.calledOnContract(contract).withArgs(args)
expect('functionName')
.not.to.be.calledOnContract(contract)
.withArgs(args)
2)
expect('functionName').to.be.calledOnContract(contract)
expect('functionName').not.to.be.calledOnContract(contract)
expect('functionName').to.be.calledOnContractWith(contract, ...)
expect('functionName').not.to.be.calledOnContractWith(contract, ...)
3) Other ideas:
expect('functionName').to.be.triggeredOn(contract)
expect('functionName').to.be.sendMsgTo(contract) On the call with @sz-piotr @Jozwiaczek we decided to implement 2). |
Add matchers for checking if the mock contract function was called with specific arguments.
Example:
The text was updated successfully, but these errors were encountered: