lundi 30 mars 2015

Angular testing, mocking rootscope

I am trying to mock the rootScope.$id property and I am doing something incorrectly that I can't quite put my finger on. So I am using karma/jasmine and sinon for the stubbing . Here's what I have -


uptop - defining the mock



var mockRootScope = {
$id: sinon.stub()
};


Then in the before each



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


And trying to set it in the unit-test like so



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


Doesn't seem to be mocking it up correctly - Any idea what I'm doing wrong here? Thanks!


Aucun commentaire:

Enregistrer un commentaire