lundi 22 décembre 2014

$injector is not working in my test why?

-$injector is not working in my test why?-


Why it is not able to return my service?


foo.service.js:



'use strict';

angular.module('fooApp')
.factory('FooService', function () {

var function1 = function function1(value) {
return value;
};

return {
function1 : function1
};
});


my test(foo.service.spec.js)



'use strict';

describe('Service: FooService', function () {
beforeEach(module('fooApp'));

var FooService;

beforeEach(function(){
inject(function ($injector) {
FooService= $injector.get('FooService');
});
});

it('should...', function(){
expect(FooService.function1('...')).toEqual(...);
....

});

....
});


When I evaluate FooService is undefined. Why ?


Error stacktrace:



...
TypeError: 'undefined' is not an object (evaluating 'FooService.function1')
...

Aucun commentaire:

Enregistrer un commentaire