Skip to content

Conversation

@notanengineercom
Copy link
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
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
Copy link
Owner

ffMathy commented Feb 12, 2020

Very nice additions! Do all tests pass?

@notanengineercom
Copy link
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