Hi everyone,
I'm new to Jasmine and got a quick question. I got a service, in which, it
invokes a mock REST service. I want to test whether the service gets the
data properly. The problem is the mock service (BUI.get) is not executed
when I inject the service. Is there a way to invoke this manually?
Thanks,
Stan
/* My controller snippet */
var myController = angular.module('myController',[]);
myController.factory("myService",['$rootScope','BUI', function($rootScope,BUI)
{
var myData = {};
myData.data = [];
myData.getData = function() {
BUI.get({resourceURI:'GetData'}, function(data) { //Success
myData.data = data;
});
}
return myData;
}])
/* My Jasmine snippet */
describe('My Unit Tests',function() {
beforeEach(module('myApp'));
describe('Invoking myService', function() {
beforeEach(module('myController'));
it('returns available sample data', inject(function(myService) {
expect(myService.data.length).toEqual(5);
}));
});
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.