From 3ab49538a414a36c97ed3735c2473eefcf7be073 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 13 Oct 2010 10:51:16 -0700 Subject: fixed issue where ng:bind would not reset value if expression returned undefined --- test/directivesSpec.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'test/directivesSpec.js') 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('
'); + 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('
'); scope.html = '
hello
'; @@ -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('
before
after
'); - expect(scope.$element.text()).toEqual("beforeHELLOafter"); + expect(sortedHtml(scope.$element)).toEqual('
before
HELLO
after
'); }); }); -- cgit v1.2.3