Consider log.js has function:
var function processData()
{
if(condition)
dbInsert();
}
var function dbInsert()
{
// do some insertion
}
Now I want to test that when processData is called whether dbInsert is called or not. This is my test.js. Which fails test on the last one although when I manually check the db there does exist an entry
it('n number of times called', function() {
var Data = '{"name":"abc"}';
var spy = sinon.spy(log, "processData");
var spy2 = sinon.spy(log, "dbInsertion");
log.processServerLog(Data);
expect(spy.callCount).to.be.equal(1);
expect(spy2.called).to.be.true; // returns false ..
});
Aucun commentaire:
Enregistrer un commentaire