77
rated 0 times
[
84]
[
7]
/ answers: 1 / hits: 19326
/ 12 Years ago, sun, february 10, 2013, 12:00:00
I am trying to create a spy on a constructor, and see if it gets called -- below are my tests.
I'm using sinon-chai so the syntax is valid, but both tests fail.
var foo = function(arg) {
};
var bar = function(arg) {
var baz = new foo(arg);
};
it('foo initialized inside of this test', function() {
var spy = sinon.spy(foo);
new foo('test');
expect(spy).to.be.called;
expect(spy).to.be.calledWith('test');
});
it('foo initialized by bar()', function() {
var spy = sinon.spy(foo);
bar('test');
expect(spy).to.be.called;
expect(spy).to.be.calledWith('test');
});
More From » mocha.js