diff options
| author | Misko Hevery | 2010-10-13 10:51:16 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-10-13 10:51:16 -0700 |
| commit | 3ab49538a414a36c97ed3735c2473eefcf7be073 (patch) | |
| tree | 444810c3098d39a3867d728aec86249b1ea32506 /test/directivesSpec.js | |
| parent | 2cb9497d02afdcfc19ea52fddcd6d1f04d81ffdb (diff) | |
| download | angular.js-3ab49538a414a36c97ed3735c2473eefcf7be073.tar.bz2 | |
fixed issue where ng:bind would not reset value if expression returned undefined
Diffstat (limited to 'test/directivesSpec.js')
| -rw-r--r-- | test/directivesSpec.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/directivesSpec.js b/test/directivesSpec.js index d8f04b29..e65973dc 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -38,6 +38,16 @@ describe("directives", function(){ expect(element.text()).toEqual('misko'); }); + it('should set text to blank if undefined', function() { + var scope = compile('<div ng:bind="a"></div>'); + scope.a = 'misko'; + scope.$eval(); + expect(element.text()).toEqual('misko'); + scope.a = undefined; + scope.$eval(); + expect(element.text()).toEqual(''); + }); + it('should set html', function() { var scope = compile('<div ng:bind="html|html"></div>'); scope.html = '<div>hello</div>'; @@ -56,10 +66,11 @@ describe("directives", function(){ it('should have $element set to current bind element', function(){ angularFilter.myFilter = function(){ - this.$element.text('HELLO'); + this.$element.addClass("filter"); + return 'HELLO'; }; var scope = compile('<div>before<div ng:bind="0|myFilter"></div>after</div>'); - expect(scope.$element.text()).toEqual("beforeHELLOafter"); + expect(sortedHtml(scope.$element)).toEqual('<div>before<div class="filter" ng:bind="0|myFilter">HELLO</div>after</div>'); }); }); |
