angular.module('myApp').factory('someService', function(){
var foo = {}; // can not get access to this variable
function setData(data){
foo.data = data;
}
function getData(data){
return foo.data;
}
return {
getData: getData,
setData: setData
}
})
how to test this two functions for set and get some data from local variable in service?
describe('someService', function () {
var someService,
foo ;
beforeEach(module('myApp'));
beforeEach(inject(function (_someService_) {
someService= _someServicee_;
}));
it('should return bundle id', function () {
expect(someService.setData('test')) // foo.data toBe 'test'
});
});
how to get access to foo var in service?
Aucun commentaire:
Enregistrer un commentaire