diff options
| author | Igor Minar | 2011-02-25 14:03:02 -0800 | 
|---|---|---|
| committer | Igor Minar | 2011-03-01 17:09:25 -0800 | 
| commit | 945056b1667a69ecc4d557cc0f03894597250ced (patch) | |
| tree | 396c0ff155fe895933cbd3301874e8799fd42b65 /test/AngularSpec.js | |
| parent | 128feb267409ee45ee5225a34aab038ddf3518fa (diff) | |
| download | angular.js-945056b1667a69ecc4d557cc0f03894597250ced.tar.bz2 | |
linking function should return bound scope
angular.compile()() returns {scope:scope, view:view},
this isn't useful at all and only makes tests more verbose.
Instead, this change makes the linking function return scope directly
and if anyone needs the linked dom there are two ways to do it
documented in angular.compile.
other changes:
- moved angular.compile docs to the compiler so that they are closer to
  the compiler
- fixed some typos and updated angular.compile docs with the new return
  value
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 46 | 
1 files changed, 26 insertions, 20 deletions
| diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 5b7e33fd..2352cdf8 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -369,45 +369,51 @@ describe('angular', function(){    });    describe('compile', function(){ -    var mvc; +    var scope, template; +      afterEach(function(){ -      dealoc(mvc.view); +      dealoc(scope);      });      it('should link to existing node and create scope', function(){ -      mvc = angular.compile('<div>{{greeting = "hello world"}}</div>')(); -      expect(mvc.view.text()).toEqual('hello world'); -      expect(mvc.scope.greeting).toEqual('hello world'); +      template = angular.element('<div>{{greeting = "hello world"}}</div>'); +      scope = angular.compile(template)(); +      expect(template.text()).toEqual('hello world'); +      expect(scope.greeting).toEqual('hello world');      });      it('should link to existing node and given scope', function(){ -      var scope = angular.scope(); -      mvc = angular.compile('<div>{{greeting = "hello world"}}</div>')(scope); -      expect(mvc.view.text()).toEqual('hello world'); -      expect(mvc.scope).toEqual(scope); +      scope = angular.scope(); +      template = angular.element('<div>{{greeting = "hello world"}}</div>'); +      angular.compile(template)(scope); +      expect(template.text()).toEqual('hello world'); +      expect(scope).toEqual(scope);      });      it('should link to new node and given scope', function(){ -      var scope = angular.scope(); -      var template = jqLite('<div>{{greeting = "hello world"}}</div>'); +      scope = angular.scope(); +      template = jqLite('<div>{{greeting = "hello world"}}</div>'); +        var templateFn = angular.compile(template);        var templateClone = template.clone(); -      mvc = templateFn(scope, function(clone){ + +      templateFn(scope, function(clone){          templateClone = clone;        }); +        expect(template.text()).toEqual(''); -      expect(mvc.view.text()).toEqual('hello world'); -      expect(mvc.view).toEqual(templateClone); -      expect(mvc.scope.greeting).toEqual('hello world'); +      expect(scope.$element.text()).toEqual('hello world'); +      expect(scope.$element).toEqual(templateClone); +      expect(scope.greeting).toEqual('hello world');      });      it('should link to cloned node and create scope', function(){ -      var scope = angular.scope(); -      var template = jqLite('<div>{{greeting = "hello world"}}</div>'); -      mvc = angular.compile(template)(scope, noop); +      scope = angular.scope(); +      template = jqLite('<div>{{greeting = "hello world"}}</div>'); +      angular.compile(template)(scope, noop);        expect(template.text()).toEqual(''); -      expect(mvc.view.text()).toEqual('hello world'); -      expect(mvc.scope.greeting).toEqual('hello world'); +      expect(scope.$element.text()).toEqual('hello world'); +      expect(scope.greeting).toEqual('hello world');      });    });  }); | 
