--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/uyvDBPJxPM0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
describe('Testing promise', function() {
var $scope = null;
var myService = null;
var cachedInstance = {
name: 'John'
}
var rootScope = {}
//you need to indicate your module in a test
beforeEach(module('plunker'));
beforeEach(inject(function(_myService_,$rootScope) {
myService = _myService_;
myService.cachedInstance = cachedInstance;
$scope = $rootScope
}));
it('should return cached instance', function() {
var resolvedInstance = {}
myService.get().then(function(instance){
resolvedInstance = instance;
});
$scope.$digest()
expect(resolvedInstance).toBe(cachedInstance);
});
});