I didn't see this mentioned in the docs so I've worked around it for now, but it would nice for jsmocha to support it natively. The workaround:
var saved = foo.bar.Constructor;
var Temp = function() {};
foo.bar.Constructor.prototype = new Temp();
foo.bar.Constructor.prototype.expects('someMethod');
// call the code
foo.bar.Constructor = saved;
The painful part is the save/restore, though it shouldn't really be all that necessary to create the Temp constructor either.
Maybe something like:
mock_object = {};
foo.bar.Constructor.new_instances(mock_object);
mock_object.expects('someMethod');
// call the code
I didn't see this mentioned in the docs so I've worked around it for now, but it would nice for jsmocha to support it natively. The workaround:
var saved = foo.bar.Constructor;
var Temp = function() {};
foo.bar.Constructor.prototype = new Temp();
foo.bar.Constructor.prototype.expects('someMethod');
// call the code
foo.bar.Constructor = saved;
The painful part is the save/restore, though it shouldn't really be all that necessary to create the Temp constructor either.
Maybe something like:
mock_object = {};
foo.bar.Constructor.new_instances(mock_object);
mock_object.expects('someMethod');
// call the code