Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/pkg/angular/test/directive/ng_style_spec.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 library ng_style_spec; 1 library ng_style_spec;
2 2
3 import '../_specs.dart'; 3 import '../_specs.dart';
4 import 'dart:html' as dom; 4 import 'dart:html' as dom;
5 5
6 main() => describe('NgStyle', () { 6 main() => describe('NgStyle', () {
7 TestBed _; 7 TestBed _;
8 8
9 beforeEach(inject((TestBed tb) => _ = tb)); 9 beforeEach(inject((TestBed tb) => _ = tb));
10 10
11 it('should set', () { 11 it('should set', () {
12 dom.Element element = _.compile('<div ng-style="{height: \'40px\'}"></div>') ; 12 dom.Element element = _.compile('<div ng-style="{height: \'40px\'}"></div>') ;
13 _.rootScope.apply(); 13 _.rootScope.$digest();
14 expect(element.style.height).toEqual('40px'); 14 expect(element.style.height).toEqual('40px');
15 }); 15 });
16 16
17 17
18 it('should silently ignore undefined style', () { 18 it('should silently ignore undefined style', () {
19 dom.Element element = _.compile('<div ng-style="myStyle"></div>'); 19 dom.Element element = _.compile('<div ng-style="myStyle"></div>');
20 _.rootScope.apply(); 20 _.rootScope.$digest();
21 expect(element.classes.contains('ng-exception')).toBeFalsy(); 21 expect(element.classes.contains('ng-exception')).toBeFalsy();
22 }); 22 });
23 23
24 24
25 describe('preserving styles set before and after compilation', () { 25 describe('preserving styles set before and after compilation', () {
26 var scope, preCompStyle, preCompVal, postCompStyle, postCompVal, element; 26 var scope, preCompStyle, preCompVal, postCompStyle, postCompVal, element;
27 27
28 beforeEach(inject(() { 28 beforeEach(inject(() {
29 preCompStyle = 'width'; 29 preCompStyle = 'width';
30 preCompVal = '300px'; 30 preCompVal = '300px';
31 postCompStyle = 'height'; 31 postCompStyle = 'height';
32 postCompVal = '100px'; 32 postCompVal = '100px';
33 element = $('<div ng-style="styleObj"></div>'); 33 element = $('<div ng-style="styleObj"></div>');
34 element.css(preCompStyle, preCompVal); 34 element.css(preCompStyle, preCompVal);
35 document.body.append(element[0]); 35 document.body.append(element[0]);
36 _.compile(element); 36 _.compile(element);
37 scope = _.rootScope; 37 scope = _.rootScope;
38 scope.context['styleObj'] = {'margin-top': '44px'}; 38 scope['styleObj'] = {'margin-top': '44px'};
39 scope.apply(); 39 scope.$apply();
40 element.css(postCompStyle, postCompVal); 40 element.css(postCompStyle, postCompVal);
41 })); 41 }));
42 42
43 afterEach(() { 43 afterEach(() {
44 element.remove(null); 44 element.remove(null);
45 }); 45 });
46 46
47 47
48 it('should not mess up stuff after compilation', () { 48 it('should not mess up stuff after compilation', () {
49 element.css('margin', '44px'); 49 element.css('margin', '44px');
50 expect(element.css(preCompStyle)).toEqual(preCompVal); 50 expect(element.css(preCompStyle)).toEqual(preCompVal);
51 expect(element.css('margin-top')).toEqual('44px'); 51 expect(element.css('margin-top')).toEqual('44px');
52 expect(element.css(postCompStyle)).toEqual(postCompVal); 52 expect(element.css(postCompStyle)).toEqual(postCompVal);
53 }); 53 });
54 54
55 it(r'should not mess up stuff after $apply with no model changes', () { 55 it(r'should not mess up stuff after $apply with no model changes', () {
56 element.css('padding-top', '33px'); 56 element.css('padding-top', '33px');
57 scope.apply(); 57 scope.$apply();
58 expect(element.css(preCompStyle)).toEqual(preCompVal); 58 expect(element.css(preCompStyle)).toEqual(preCompVal);
59 expect(element.css('margin-top')).toEqual('44px'); 59 expect(element.css('margin-top')).toEqual('44px');
60 expect(element.css(postCompStyle)).toEqual(postCompVal); 60 expect(element.css(postCompStyle)).toEqual(postCompVal);
61 expect(element.css('padding-top')).toEqual('33px'); 61 expect(element.css('padding-top')).toEqual('33px');
62 }); 62 });
63 63
64 64
65 it(r'should not mess up stuff after $apply with non-colliding model changes' , () { 65 it(r'should not mess up stuff after $apply with non-colliding model changes' , () {
66 scope.context['styleObj'] = {'padding-top': '99px'}; 66 scope['styleObj'] = {'padding-top': '99px'};
67 scope.apply(); 67 scope.$apply();
68 expect(element.css(preCompStyle)).toEqual(preCompVal); 68 expect(element.css(preCompStyle)).toEqual(preCompVal);
69 expect(element.css('margin-top')).not.toEqual('44px'); 69 expect(element.css('margin-top')).not.toEqual('44px');
70 expect(element.css('padding-top')).toEqual('99px'); 70 expect(element.css('padding-top')).toEqual('99px');
71 expect(element.css(postCompStyle)).toEqual(postCompVal); 71 expect(element.css(postCompStyle)).toEqual(postCompVal);
72 }); 72 });
73 73
74 74
75 it(r'should overwrite original styles after a colliding model change', () { 75 it(r'should overwrite original styles after a colliding model change', () {
76 scope.context['styleObj'] = {'height': '99px', 'width': '88px'}; 76 scope['styleObj'] = {'height': '99px', 'width': '88px'};
77 scope.apply(); 77 scope.$apply();
78 expect(element.css(preCompStyle)).toEqual('88px'); 78 expect(element.css(preCompStyle)).toEqual('88px');
79 expect(element.css(postCompStyle)).toEqual('99px'); 79 expect(element.css(postCompStyle)).toEqual('99px');
80 scope.context['styleObj'] = {}; 80 scope['styleObj'] = {};
81 scope.apply(); 81 scope.$apply();
82 expect(element.css(preCompStyle)).not.toEqual('88px'); 82 expect(element.css(preCompStyle)).not.toEqual('88px');
83 expect(element.css(postCompStyle)).not.toEqual('99px'); 83 expect(element.css(postCompStyle)).not.toEqual('99px');
84 }); 84 });
85 }); 85 });
86 }); 86 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698