diff options
| author | Vojta Jina | 2010-11-07 13:18:00 +0000 | 
|---|---|---|
| committer | Igor Minar | 2010-11-07 14:42:03 -0800 | 
| commit | 7779630989e6819e59a5d0122787ed7468fb006e (patch) | |
| tree | 8956f74cfe383ed00f9cc7029b480150106e847f /test/AngularSpec.js | |
| parent | 00ca67e4befffed00ecee81bd1ce903fe01f542a (diff) | |
| download | angular.js-7779630989e6819e59a5d0122787ed7468fb006e.tar.bz2 | |
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
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 28 | 
1 files changed, 28 insertions, 0 deletions
| 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(); +  }); +}); | 
