diff options
| author | Misko Hevery | 2010-04-03 17:04:36 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-04-03 17:04:36 -0700 |
| commit | a80a61839a66d244c8bb14bbe2975746e02516c8 (patch) | |
| tree | 5a7b4d9d3e2a7a15ebf55e068782fbf2aa4ac6bf /test/ScopeSpec.js | |
| parent | 35ca4fcb9c49e505e28669e951e01ddedb01d7db (diff) | |
| download | angular.js-a80a61839a66d244c8bb14bbe2975746e02516c8.tar.bz2 | |
injection is now working
Diffstat (limited to 'test/ScopeSpec.js')
| -rw-r--r-- | test/ScopeSpec.js | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/test/ScopeSpec.js b/test/ScopeSpec.js index 8d2a0ed4..a7322cae 100644 --- a/test/ScopeSpec.js +++ b/test/ScopeSpec.js @@ -65,20 +65,6 @@ describe('scope/model', function(){ expect(model.$bind(function(){return this.name;})()).toEqual('misko'); }); - //$behavior - it('should behave as class', function(){ - function Printer(brand){ - this.brand = brand; - }; - Printer.prototype.print = function(){ - this.printed = true; - }; - var model = createScope({ name: 'parent' }, Printer, 'hp'); - expect(model.brand).toEqual('hp'); - model.print(); - expect(model.printed).toEqual(true); - }); - //$tryEval it('should report error on element', function(){ var scope = createScope(); @@ -108,16 +94,6 @@ describe('scope/model', function(){ expect(scope.log).toEqual('first;middle;last;'); }); - // Services are initialized - it("should inject services", function(){ - var scope = createScope(serviceAdapter({ - $window: function(){ - return window; - } - })); - expect(scope.$window).toEqual(window); - }); - it("should have $root and $parent", function(){ var parent = createScope(); var scope = createScope(parent); @@ -125,4 +101,37 @@ describe('scope/model', function(){ expect(scope.$parent).toEqual(parent); }); + // Service injection + it('should inject services', function(){ + var scope = createScope(null, { + service:function(){ + return "ABC"; + } + }); + expect(scope.service).toEqual("ABC"); + }); + + it('should inject arugments', function(){ + var scope = createScope(null, { + name:function(){ + return "misko"; + }, + greet: extend(function(name) { + return 'hello ' + name; + }, {inject:['name']}) + }); + expect(scope.greet).toEqual("hello misko"); + }); + + it('should throw error on missing dependency', function(){ + try { + createScope(null, { + greet: extend(function(name) { + }, {inject:['name']}) + }); + } catch(e) { + expect(e).toEqual("Don't know how to inject 'name'."); + } + }); + }); |
