Skip to content

Implement didNotReceive and bug fixes - #78

Merged
ffMathy merged 5 commits into
ffMathy:masterfrom
notanengineercom:didnotreceive-and-bug-fixes
Feb 13, 2020
Merged

Implement didNotReceive and bug fixes#78
ffMathy merged 5 commits into
ffMathy:masterfrom
notanengineercom:didnotreceive-and-bug-fixes

Conversation

@notanengineercom

Copy link
Copy Markdown
Collaborator
  • Fixes Working use case of didNotReceive? #72
  • Fixes an issue where .received(0) of a non mocked method / property of a Substituted class would throw an error complaining about the method / property not being mocked.
  • Implements didNotReceive
  • Fixes also a bug that prevented an assertion to be run when having the following setup:
const calculator = Substitute.for<Calculator>();
calculator.mode = true;
void calculator.mode;
calculator.received(1).mode = true;

The issue was that Context.state was being overriden from SetPropertyState to a GetPropertyState when calling void calculator.mode. So when doing the evaluation calculator.received(1).mode = true Context.set was calling the GetPropertyState.set method, instead of the expected SetPropertyState.set. Probably the same issue happens for the reverse (first performing a get, then a set).


I updated AVA to latest, and ran npm audit fix. Had to fix a few tests because of the AVA upgrade

@notanengineercom

Copy link
Copy Markdown
Collaborator Author

Also I would sugges two things:

  • Would be great to add lint rules, the code has different styles (mixed use of semicolons)
  • Instead of throwing a Error, it would be better to throw SubstituteError or something similar

I'm working on another bug fix and a new feature for it, so I'm more than happy to add these stuff if we agree on it!

@ffMathy

ffMathy commented Feb 12, 2020

Copy link
Copy Markdown
Owner

Very nice additions! Do all tests pass?

@notanengineercom

Copy link
Copy Markdown
Collaborator Author

Yes! All 43

@ffMathy
ffMathy merged commit b8f1d43 into ffMathy:master Feb 13, 2020
@notanengineercom
notanengineercom deleted the didnotreceive-and-bug-fixes branch February 13, 2020 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Working use case of didNotReceive?

2 participants