Note: I will answer my own question, but if you have a better answer, I’ll accept it over mine.
I have a function that looks like this:
function systemUnderTest(func, param) {
param.firstProperty = !param.firstProperty;
func();
param.secondProperty = !param.secondProperty;
}
I would like to stub param
and assert that param.firstProperty
is assigned before func()
. I would also like to check that func()
is called before param.secondProperty
is set.
Sinon comes with spy.calledBefore(anotherSpy)
and this seems like the right tool for the job, but I’m not sure how to set up param
, an object literal, to record the order in which its properties/accessors are used.
How do I set up param
so I can call x.calledBefore(y)
on its properties?