Open awvalenti opened 4 years ago
Ideally, I'd like to also make sure that no other calls were made, even with different number of arguments, something like:
verify(MockDocument.addEventListener).singlyCalledWith('keydown', myOnKeyDown))
which would prevent:
document.addEventListener(null, null, null)
Hey, so you would like to be sure that there were no other calls than those that you've verified? Do I understand it correctly?
For example:
// when
foo.sumTwoNumbers(2, 3);
foo.sumTwoNumbers(2, 5);
// then
verify(mockedFoo.sumTwoNumbers(2, 3)).once().AND_NOTHING_ELSE();
Where AND_NOTHING_ELSE
will additionally check that there were no other calls?
Yes, that is correct.
Hello. I would like to verify that my function was called exactly once AND with specific args. I noticed this verification:
accepts the following production code
once
is being applied only to calls with'keydown'
andmyOnKeyDown
. If other args are used, they are considered another call, andonce
doesn't catch it.As a workaround, I did the following:
Is there an easier way?
Thanks!