samedi 7 mars 2015

Jasmine spyOn not working

I am fairly new to Jasmine, and I have to test a few function calls:


JS CODE



object1 = {

function1: function() {
// object1.function2 is a callback
object2.someFunction("called", object1.function2)
},

function2: function() {
// code to do stuff
}

}`


TEST CODE



describe("test suite", function(){
it("test1", function(){
spyOn(object1, "function2");
object1.function1();
expect(object1.function2).toHaveBeenCalled();
});
});


I've tried the above but it fails, and says "Expected spy function2 to have been called". Can somebody help me out with this ? Thanks


Aucun commentaire:

Enregistrer un commentaire