Added tests for angular.service

- should allow to override a service
- should preserve angular properties on override
- should not preserve non-angular properties on override
This commit is contained in:
Vojta Jina 2010-11-07 13:18:00 +00:00 committed by Igor Minar
parent 00ca67e4be
commit 7779630989

View file

@ -300,3 +300,31 @@ describe('extensionMap', function() {
expect(result.two).not.toBeDefined();
});
});
describe('angular service', function() {
it('should override services', function() {
var scope = createScope();
angular.service('fake', function() { return 'old'; });
angular.service('fake', function() { return 'new'; });
expect(scope.$inject('fake')).toEqual('new');
});
it('should preserve $ properties on override', function() {
angular.service('fake', {$one: true}, {$two: true});
var result = angular.service('fake', {$third: true});
expect(result.$one).toBeTruthy();
expect(result.$two).toBeTruthy();
expect(result.$third).toBeTruthy();
});
it('should not preserve non-angular properties on override', function() {
angular.service('fake', {one: true}, {two: true});
var result = angular.service('fake', {third: true});
expect(result.one).not.toBeDefined();
expect(result.two).not.toBeDefined();
expect(result.third).toBeTruthy();
});
});