How can I use the Sinon package to stub/mock a method call where one of the parameters I have to mock is called using an arrow function? eg
let objWithMethod = { method : function(x) {}; };
function SUT() {
// use case
let x = 'some value';
let y = { anotherMethod : function(func) {}; };
// I want to test that `y.anotherMethod()` is called with
// `(x) => objWithMethod.method(x)` as the argument
y.anotherMethod((x) => objWithMethod.method(x));
}
let mockObj = sinon.mock(objWithMethod);
// Both of these fail with a "never called" error
mockObj.expects('method').once().withArgs(objWithMethod.method.bind(this, x));
mockObj.expects('method').once().withArgs((x) => objWithMethod.method(x));
SUT();
mockObj.verify();
I couldn't find anything in the sinon docs nor after a few attempts at a google search.