Perhaps this is a simple question, but I am new in unit testing and angular, what is the correct approach for write tests for services, that return/set/modify data.
angular.module('myApp').service('optionsService', function(){
var options = {};
var getOptions = function(){
return options;
},
var setOptions = function(options){
options = options;
}
return: {
getOptions: getOptions,
setOptions: setOptions
}
})
describe('optionsService', function(){
var optionsService;
beforeEach(module('myApp'));
beforeEach(injector(function(_optionsService_){
optionsService= _optionsService_;
}))
it('should exist', function(){
expect(optionsService).toBeDefined();
})
it('getOptions should return object', function(){
// help
})
it('setOptions should set new options', function(){
// help
})
})
Do you know good resources for deep dive for learning unit testing with jasmine. Thanks everyone!
Aucun commentaire:
Enregistrer un commentaire