From e3e9ac86750b20fb8ad6765011e06d569899612d Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 14 Jul 2010 17:07:23 -0700 Subject: ng:style remembers previous style and properly resets to it --- test/directivesSpec.js | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'test/directivesSpec.js') diff --git a/test/directivesSpec.js b/test/directivesSpec.js index ef4814bf..8ce949aa 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -168,17 +168,30 @@ describe("directives", function(){ expect(e2.hasClass('even')).toBeTruthy(); }); - it('should ng:style', function(){ - var scope = compile('
'); - scope.$eval(); - expect(element.css('color')).toEqual('red'); - }); + describe('ng:style', function(){ + it('should set', function(){ + var scope = compile(''); + scope.$eval(); + expect(element.css('color')).toEqual('red'); + }); - it('should silently ignore undefined ng:style', function() { - var scope = compile(''); - scope.$eval(); - dump(sortedHtml(element)); - expect(element.hasClass('ng-exception')).toBeFalsy(); + it('should silently ignore undefined style', function() { + var scope = compile(''); + scope.$eval(); + expect(element.hasClass('ng-exception')).toBeFalsy(); + }); + + it('should preserve and remove previus style', function(){ + var scope = compile(''); + scope.$eval(); + expect(element.css()).toEqual({color:'red'}); + scope.myStyle = {color:'blue', width:'10px'}; + scope.$eval(); + expect(element.css()).toEqual({color:'blue', width:'10px'}); + scope.myStyle = {}; + scope.$eval(); + expect(element.css()).toEqual({color:'red'}); + }); }); it('should ng:show', function(){ -- cgit v1.2.3