mercredi 8 avril 2015

Angular, sinon stub not performing correctly

I am trying to mock a rootscope for a unit (karma/jasmine) test here, and it doesn't seem to be working. I'm not sure why and could use some help. Here it is :


Declaring it up top :



var mockRootScope = sinon.stub();


Inside the before each :



angularMocks.module(function($provide) {
$provide.value('$rootScope', mockRootScope);
});


Then inside the unit test itself



mockRootScope.returns({
$id: 1
});
console.log(mockRootScope.$id);


the log is coming back undefined. if I log mockRootScope it tells me it's a stub (which is good), but I can't seem to figure out why it isn't returning correct values. Thanks!


Aucun commentaire:

Enregistrer un commentaire