diff options
| author | Misko Hevery | 2010-07-14 17:07:23 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-07-14 17:07:23 -0700 |
| commit | e3e9ac86750b20fb8ad6765011e06d569899612d (patch) | |
| tree | 51545a0a65f3056c54d213579b19e9f782e2fe00 /test/directivesSpec.js | |
| parent | 0a57273f0000421639c926d4d180680e3a64c0f7 (diff) | |
| download | angular.js-e3e9ac86750b20fb8ad6765011e06d569899612d.tar.bz2 | |
ng:style remembers previous style and properly resets to it
Diffstat (limited to 'test/directivesSpec.js')
| -rw-r--r-- | test/directivesSpec.js | 33 |
1 files changed, 23 insertions, 10 deletions
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('<div ng:style="{color:\'red\'}"></div>'); - scope.$eval(); - expect(element.css('color')).toEqual('red'); - }); + describe('ng:style', function(){ + it('should set', function(){ + var scope = compile('<div ng:style="{color:\'red\'}"></div>'); + scope.$eval(); + expect(element.css('color')).toEqual('red'); + }); - it('should silently ignore undefined ng:style', function() { - var scope = compile('<div ng:style="myStyle"></div>'); - scope.$eval(); - dump(sortedHtml(element)); - expect(element.hasClass('ng-exception')).toBeFalsy(); + it('should silently ignore undefined style', function() { + var scope = compile('<div ng:style="myStyle"></div>'); + scope.$eval(); + expect(element.hasClass('ng-exception')).toBeFalsy(); + }); + + it('should preserve and remove previus style', function(){ + var scope = compile('<div style="color:red;" ng:style="myStyle"></div>'); + 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(){ |
