From 7779630989e6819e59a5d0122787ed7468fb006e Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Sun, 7 Nov 2010 13:18:00 +0000 Subject: 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 --- test/AngularSpec.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/AngularSpec.js') diff --git a/test/AngularSpec.js b/test/AngularSpec.js index d5005151..e5cf2dd1 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -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(); + }); +}); -- cgit v1.2.3