jeudi 2 avril 2015

Change Angular mock value

I have an unit test that look like this:



describe("myDirective Test",function(){
beforeEach(module('app'));

beforeEach(function() {
module(function($provide) {
$provide.constant('Config', {"showmenu":true});
});
});

it('should add showmenu attribute',inject(function($compile,$rootScope){
var element = $compile('<div my-directive></div>')($rootScope);
expect(element.attr('showmenu')).not.toBe(undefined);
}));

it('should NOT add showmenu attribute',inject(function($compile,$rootScope){
var element = $compile('<div my-directive></div>')($rootScope);
expect(element.attr('showmenu')).toBe(undefined);
}));
});


How can I change the showmenu value, so that it is false in the should NOT add showmenu attribute test?


Aucun commentaire:

Enregistrer un commentaire