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

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

Issue 180873006: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback Created 6 years, 10 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 form_spec; 1 library form_spec;
2 2
3 import '../_specs.dart'; 3 import '../_specs.dart';
4 4
5 main() => 5 main() =>
6 describe('form', () { 6 describe('form', () {
7 TestBed _; 7 TestBed _;
8 8
9 beforeEach(inject((TestBed tb) => _ = tb)); 9 it('should set the name of the form and attach it to the scope', inject((Scope scope, TestBed _) {
10
11 it('should set the name of the form and attach it to the scope', inject((Scope scope) {
12 var element = $('<form name="myForm"></form>'); 10 var element = $('<form name="myForm"></form>');
13 11
14 expect(scope['myForm']).toBeNull(); 12 expect(scope.context['myForm']).toBeNull();
15 13
16 _.compile(element); 14 _.compile(element);
17 scope.$apply(); 15 scope.apply();
18 16
19 expect(scope['myForm']).toBeDefined(); 17 expect(scope.context['myForm']).toBeDefined();
20 18
21 var form = scope['myForm']; 19 var form = scope.context['myForm'];
22 expect(form.name).toEqual('myForm'); 20 expect(form.name).toEqual('myForm');
23 })); 21 }));
24 22
25 describe('pristine / dirty', () { 23 describe('pristine / dirty', () {
26 it('should be set to pristine by default', inject((Scope scope) { 24 it('should be set to pristine by default', inject((Scope scope, TestBed _) {
27 var element = $('<form name="myForm"></form>'); 25 var element = $('<form name="myForm"></form>');
28 26
29 _.compile(element); 27 _.compile(element);
30 scope.$apply(); 28 scope.apply();
31 29
32 var form = scope['myForm']; 30 var form = scope.context['myForm'];
33 expect(form.pristine).toEqual(true); 31 expect(form.pristine).toEqual(true);
34 expect(form.dirty).toEqual(false); 32 expect(form.dirty).toEqual(false);
35 })); 33 }));
36 34
37 it('should add and remove the correct CSS classes when set to dirty and to p ristine', inject((Scope scope) { 35 it('should add and remove the correct CSS classes when set to dirty and to p ristine', inject((Scope scope, TestBed _) {
38 var element = $('<form name="myForm"></form>'); 36 var element = $('<form name="myForm"></form>');
39 37
40 _.compile(element); 38 _.compile(element);
41 scope.$apply(); 39 scope.apply();
42 40
43 var form = scope['myForm']; 41 var form = scope.context['myForm'];
44 42
45 form.dirty = true; 43 form.dirty = true;
46 expect(form.pristine).toEqual(false); 44 expect(form.pristine).toEqual(false);
47 expect(form.dirty).toEqual(true); 45 expect(form.dirty).toEqual(true);
48 expect(element.hasClass('ng-pristine')).toBe(false); 46 expect(element.hasClass('ng-pristine')).toBe(false);
49 expect(element.hasClass('ng-dirty')).toBe(true); 47 expect(element.hasClass('ng-dirty')).toBe(true);
50 48
51 form.pristine = true; 49 form.pristine = true;
52 expect(form.pristine).toEqual(true); 50 expect(form.pristine).toEqual(true);
53 expect(form.dirty).toEqual(false); 51 expect(form.dirty).toEqual(false);
54 expect(element.hasClass('ng-pristine')).toBe(true); 52 expect(element.hasClass('ng-pristine')).toBe(true);
55 expect(element.hasClass('ng-dirty')).toBe(false); 53 expect(element.hasClass('ng-dirty')).toBe(false);
56 })); 54 }));
57 }); 55 });
58 56
59 describe('valid / invalid', () { 57 describe('valid / invalid', () {
60 it('should add and remove the correct flags when set to valid and to invalid ', inject((Scope scope) { 58 it('should add and remove the correct flags when set to valid and to invalid ', inject((Scope scope, TestBed _) {
61 var element = $('<form name="myForm"></form>'); 59 var element = $('<form name="myForm"></form>');
62 60
63 _.compile(element); 61 _.compile(element);
64 scope.$apply(); 62 scope.apply();
65 63
66 var form = scope['myForm']; 64 var form = scope.context['myForm'];
67 65
68 form.invalid = true; 66 form.invalid = true;
69 expect(form.valid).toEqual(false); 67 expect(form.valid).toEqual(false);
70 expect(form.invalid).toEqual(true); 68 expect(form.invalid).toEqual(true);
71 expect(element.hasClass('ng-valid')).toBe(false); 69 expect(element.hasClass('ng-valid')).toBe(false);
72 expect(element.hasClass('ng-invalid')).toBe(true); 70 expect(element.hasClass('ng-invalid')).toBe(true);
73 71
74 form.valid = true; 72 form.valid = true;
75 expect(form.valid).toEqual(true); 73 expect(form.valid).toEqual(true);
76 expect(form.invalid).toEqual(false); 74 expect(form.invalid).toEqual(false);
77 expect(element.hasClass('ng-invalid')).toBe(false); 75 expect(element.hasClass('ng-invalid')).toBe(false);
78 expect(element.hasClass('ng-valid')).toBe(true); 76 expect(element.hasClass('ng-valid')).toBe(true);
79 })); 77 }));
80 78
81 it('should set the validity with respect to all existing validations when se tValidity() is used', inject((Scope scope) { 79 it('should set the validity with respect to all existing validations when se tValidity() is used', inject((Scope scope, TestBed _) {
82 var element = $('<form name="myForm">' + 80 var element = $('<form name="myForm">'
83 ' <input type="text" ng-model="one" name="one" />' + 81 ' <input type="text" ng-model="one" name="one" />' +
84 ' <input type="text" ng-model="two" name="two" />' + 82 ' <input type="text" ng-model="two" name="two" />' +
85 ' <input type="text" ng-model="three" name="three" />' + 83 ' <input type="text" ng-model="three" name="three" />' +
86 '</form>'); 84 '</form>');
87 85
88 _.compile(element); 86 _.compile(element);
89 scope.$apply(); 87 scope.apply();
90 88
91 var form = scope['myForm']; 89 var form = scope.context['myForm'];
92 NgModel one = form['one']; 90 NgModel one = form['one'];
93 NgModel two = form['two']; 91 NgModel two = form['two'];
94 NgModel three = form['three']; 92 NgModel three = form['three'];
95 93
96 form.setValidity(one, "some error", false); 94 form.updateControlValidity(one, "some error", false);
97 expect(form.valid).toBe(false); 95 expect(form.valid).toBe(false);
98 expect(form.invalid).toBe(true); 96 expect(form.invalid).toBe(true);
99 97
100 form.setValidity(two, "some error", false); 98 form.updateControlValidity(two, "some error", false);
101 expect(form.valid).toBe(false); 99 expect(form.valid).toBe(false);
102 expect(form.invalid).toBe(true); 100 expect(form.invalid).toBe(true);
103 101
104 form.setValidity(one, "some error", true); 102 form.updateControlValidity(one, "some error", true);
105 expect(form.valid).toBe(false); 103 expect(form.valid).toBe(false);
106 expect(form.invalid).toBe(true); 104 expect(form.invalid).toBe(true);
107 105
108 form.setValidity(two, "some error", true); 106 form.updateControlValidity(two, "some error", true);
109 expect(form.valid).toBe(true); 107 expect(form.valid).toBe(true);
110 expect(form.invalid).toBe(false); 108 expect(form.invalid).toBe(false);
111 })); 109 }));
112 110
113 it('should not handle the control + errorType pair more than once', inject(( Scope scope) { 111 it('should not handle the control errorType pair more than once', inject((Sc ope scope, TestBed _) {
114 var element = $('<form name="myForm">' + 112 var element = $('<form name="myForm">'
115 ' <input type="text" ng-model="one" name="one" />' + 113 ' <input type="text" ng-model="one" name="one" />' +
116 '</form>'); 114 '</form>');
117 115
118 _.compile(element); 116 _.compile(element);
119 scope.$apply(); 117 scope.apply();
120 118
121 var form = scope['myForm']; 119 var form = scope.context['myForm'];
122 NgModel one = form['one']; 120 NgModel one = form['one'];
123 121
124 form.setValidity(one, "validation error", false); 122 form.updateControlValidity(one, "validation error", false);
125 expect(form.valid).toBe(false); 123 expect(form.valid).toBe(false);
126 expect(form.invalid).toBe(true); 124 expect(form.invalid).toBe(true);
127 125
128 form.setValidity(one, "validation error", false); 126 form.updateControlValidity(one, "validation error", false);
129 expect(form.valid).toBe(false); 127 expect(form.valid).toBe(false);
130 expect(form.invalid).toBe(true); 128 expect(form.invalid).toBe(true);
131 129
132 form.setValidity(one, "validation error", true); 130 form.updateControlValidity(one, "validation error", true);
133 expect(form.valid).toBe(true); 131 expect(form.valid).toBe(true);
134 expect(form.invalid).toBe(false); 132 expect(form.invalid).toBe(false);
135 })); 133 }));
136 134
137 it('should update the validity of the parent form when the inner model chang es', inject((Scope scope) { 135 it('should update the validity of the parent form when the inner model chang es', inject((Scope scope, TestBed _) {
138 var element = $('<form name="myForm">' + 136 var element = $('<form name="myForm">'
139 ' <input type="text" ng-model="one" name="one" />' + 137 ' <input type="text" ng-model="one" name="one" />' +
140 ' <input type="text" ng-model="two" name="two" />' + 138 ' <input type="text" ng-model="two" name="two" />' +
141 '</form>'); 139 '</form>');
142 140
143 _.compile(element); 141 _.compile(element);
144 scope.$apply(); 142 scope.apply();
145 143
146 var form = scope['myForm']; 144 var form = scope.context['myForm'];
147 NgModel one = form['one']; 145 NgModel one = form['one'];
148 NgModel two = form['two']; 146 NgModel two = form['two'];
149 147
150 one.setValidity("required", false); 148 one.setValidity("required", false);
151 expect(form.valid).toBe(false); 149 expect(form.valid).toBe(false);
152 expect(form.invalid).toBe(true); 150 expect(form.invalid).toBe(true);
153 151
154 two.setValidity("required", false); 152 two.setValidity("required", false);
155 expect(form.valid).toBe(false); 153 expect(form.valid).toBe(false);
156 expect(form.invalid).toBe(true); 154 expect(form.invalid).toBe(true);
157 155
158 one.setValidity("required", true); 156 one.setValidity("required", true);
159 expect(form.valid).toBe(false); 157 expect(form.valid).toBe(false);
160 expect(form.invalid).toBe(true); 158 expect(form.invalid).toBe(true);
161 159
162 two.setValidity("required", true); 160 two.setValidity("required", true);
163 expect(form.valid).toBe(true); 161 expect(form.valid).toBe(true);
164 expect(form.invalid).toBe(false); 162 expect(form.invalid).toBe(false);
165 })); 163 }));
166 164
167 it('should set the validity for the parent form when fieldsets are used', in ject((Scope scope) { 165 it('should set the validity for the parent form when fieldsets are used', in ject((Scope scope, TestBed _) {
168 var element = $('<form name="myForm">' + 166 var element = $('<form name="myForm">'
169 ' <fieldset probe="f">' + 167 ' <fieldset probe="f">' +
170 ' <input type="text" ng-model="one" name="one" probe="m " />' + 168 ' <input type="text" ng-model="one" name="one" probe="m " />' +
171 ' </fieldset>' + 169 ' </fieldset>' +
172 '</form>'); 170 '</form>');
173 171
174 _.compile(element); 172 _.compile(element);
175 scope.$apply(); 173 scope.apply();
176 174
177 var form = scope['myForm']; 175 var form = scope.context['myForm'];
178 var fieldset = _.rootScope.f.directive(NgForm); 176 var fieldset = _.rootScope.context['f'].directive(NgForm);
179 var model = _.rootScope.m.directive(NgModel); 177 var model = _.rootScope.context['m'].directive(NgModel);
180 178
181 model.setValidity("error", false); 179 model.setValidity("error", false);
182 180
183 expect(model.valid).toBe(false); 181 expect(model.valid).toBe(false);
184 expect(fieldset.valid).toBe(false); 182 expect(fieldset.valid).toBe(false);
185 expect(form.valid).toBe(false); 183 expect(form.valid).toBe(false);
186 184
187 model.setValidity("error", true); 185 model.setValidity("error", true);
188 186
189 expect(model.valid).toBe(true); 187 expect(model.valid).toBe(true);
190 expect(fieldset.valid).toBe(true); 188 expect(fieldset.valid).toBe(true);
191 expect(form.valid).toBe(true); 189 expect(form.valid).toBe(true);
192 190
193 form.setValidity(fieldset, "error", false); 191 form.updateControlValidity(fieldset, "error", false);
194 expect(model.valid).toBe(true); 192 expect(model.valid).toBe(true);
195 expect(fieldset.valid).toBe(true); 193 expect(fieldset.valid).toBe(true);
196 expect(form.valid).toBe(false); 194 expect(form.valid).toBe(false);
197 195
198 fieldset.setValidity(model, "error", false); 196 fieldset.updateControlValidity(model, "error", false);
199 expect(model.valid).toBe(true); 197 expect(model.valid).toBe(true);
200 expect(fieldset.valid).toBe(false); 198 expect(fieldset.valid).toBe(false);
201 expect(form.valid).toBe(false); 199 expect(form.valid).toBe(false);
202 })); 200 }));
203 }); 201 });
204 202
205 describe('controls', () { 203 describe('controls', () {
206 it('should add each contained ng-model as a control upon compile', inject((S cope scope) { 204 it('should add each contained ng-model as a control upon compile', inject((S cope scope, TestBed _) {
207 var element = $('<form name="myForm">' + 205 var element = $('<form name="myForm">'
208 ' <input type="text" ng-model="mega_model" name="mega_nam e" />' + 206 ' <input type="text" ng-model="mega_model" name="mega_nam e" />' +
209 ' <select ng-model="fire_model" name="fire_name">' + 207 ' <select ng-model="fire_model" name="fire_name">' +
210 ' <option>value</option>' + 208 ' <option>value</option>'
211 ' </select>' + 209 ' </select>' +
212 '</form>'); 210 '</form>');
213 211
214 _.compile(element); 212 _.compile(element);
215 213
216 scope.mega_model = 'mega'; 214 scope.context['mega_model'] = 'mega';
217 scope.fire_model = 'fire'; 215 scope.context['fire_model'] = 'fire';
218 scope.$apply(); 216 scope.apply();
219 217
220 var form = scope['myForm']; 218 var form = scope.context['myForm'];
221 expect(form['mega_name'].modelValue).toBe('mega'); 219 expect(form['mega_name'].modelValue).toBe('mega');
222 expect(form['fire_name'].modelValue).toBe('fire'); 220 expect(form['fire_name'].modelValue).toBe('fire');
223 })); 221 }));
224 222
225 it('should properly remove controls directly from the ngForm instance', inje ct((Scope scope) { 223 it('should properly remove controls directly from the ngForm instance', inje ct((Scope scope, TestBed _) {
226 var element = $('<form name="myForm">' + 224 var element = $('<form name="myForm">'
227 ' <input type="text" ng-model="mega_model" name="mega_con trol" />' + 225 ' <input type="text" ng-model="mega_model" name="mega_con trol" />' +
228 '</form>'); 226 '</form>');
229 227
230 _.compile(element); 228 _.compile(element);
231 scope.$apply(); 229 scope.apply();
232 230
233 var form = scope['myForm']; 231 var form = scope.context['myForm'];
234 var control = form['mega_control']; 232 var control = form['mega_control'];
235 form.removeControl(control); 233 form.removeControl(control);
236 expect(form['mega_control']).toBeNull(); 234 expect(form['mega_control']).toBeNull();
237 })); 235 }));
238 236
239 it('should remove all controls when the scope is destroyed', inject((Scope s cope) { 237 it('should remove all controls when the scope is destroyed', inject((Scope s cope, TestBed _) {
240 Scope childScope = scope.$new(); 238 Scope childScope = scope.createChild({});
241 var element = $('<form name="myForm">' + 239 var element = $('<form name="myForm">' +
242 ' <input type="text" ng-model="one" name="one" />' + 240 ' <input type="text" ng-model="one" name="one" />' +
243 ' <input type="text" ng-model="two" name="two" />' + 241 ' <input type="text" ng-model="two" name="two" />' +
244 ' <input type="text" ng-model="three" name="three" />' + 242 ' <input type="text" ng-model="three" name="three" />' +
245 '</form>'); 243 '</form>');
246 244
247 _.compile(element, scope: childScope); 245 _.compile(element, scope: childScope);
248 childScope.$apply(); 246 childScope.apply();
249 247
250 var form = childScope['myForm']; 248 var form = childScope.context['myForm'];
251 expect(form['one']).toBeDefined(); 249 expect(form['one']).toBeDefined();
252 expect(form['two']).toBeDefined(); 250 expect(form['two']).toBeDefined();
253 expect(form['three']).toBeDefined(); 251 expect(form['three']).toBeDefined();
254 252
255 childScope.$destroy(); 253 childScope.destroy();
256 254
257 expect(form['one']).toBeNull(); 255 expect(form['one']).toBeNull();
258 expect(form['two']).toBeNull(); 256 expect(form['two']).toBeNull();
259 expect(form['three']).toBeNull(); 257 expect(form['three']).toBeNull();
260 })); 258 }));
261 }); 259 });
262 260
263 describe('onSubmit', () { 261 describe('onSubmit', () {
264 it('should suppress the submission event if no action is provided within the form', inject((Scope scope) { 262 it('should suppress the submission event if no action is provided within the form', inject((Scope scope, TestBed _) {
265 var element = $('<form name="myForm"></form>'); 263 var element = $('<form name="myForm"></form>');
266 264
267 _.compile(element); 265 _.compile(element);
268 scope.$apply(); 266 scope.apply();
269 267
270 Event submissionEvent = new Event.eventType('CustomEvent', 'submit'); 268 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
271 269
272 expect(submissionEvent.defaultPrevented).toBe(false); 270 expect(submissionEvent.defaultPrevented).toBe(false);
273 element[0].dispatchEvent(submissionEvent); 271 element[0].dispatchEvent(submissionEvent);
274 expect(submissionEvent.defaultPrevented).toBe(true); 272 expect(submissionEvent.defaultPrevented).toBe(true);
275 273
276 Event fakeEvent = new Event.eventType('CustomEvent', 'running'); 274 Event fakeEvent = new Event.eventType('CustomEvent', 'running');
277 275
278 expect(fakeEvent.defaultPrevented).toBe(false); 276 expect(fakeEvent.defaultPrevented).toBe(false);
279 element[0].dispatchEvent(submissionEvent); 277 element[0].dispatchEvent(submissionEvent);
280 expect(fakeEvent.defaultPrevented).toBe(false); 278 expect(fakeEvent.defaultPrevented).toBe(false);
281 })); 279 }));
282 280
283 it('should not prevent the submission event if an action is defined', inject ((Scope scope) { 281 it('should not prevent the submission event if an action is defined', inject ((Scope scope, TestBed _) {
284 var element = $('<form name="myForm" action="..."></form>'); 282 var element = $('<form name="myForm" action="..."></form>');
285 283
286 _.compile(element); 284 _.compile(element);
287 scope.$apply(); 285 scope.apply();
288 286
289 Event submissionEvent = new Event.eventType('CustomEvent', 'submit'); 287 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
290 288
291 expect(submissionEvent.defaultPrevented).toBe(false); 289 expect(submissionEvent.defaultPrevented).toBe(false);
292 element[0].dispatchEvent(submissionEvent); 290 element[0].dispatchEvent(submissionEvent);
293 expect(submissionEvent.defaultPrevented).toBe(false); 291 expect(submissionEvent.defaultPrevented).toBe(false);
294 })); 292 }));
295 293
296 it('should execute the ng-submit expression if provided upon form submission ', inject((Scope scope) { 294 it('should execute the ng-submit expression if provided upon form submission ', inject((Scope scope, TestBed _) {
297 var element = $('<form name="myForm" ng-submit="submitted = true"></form>' ); 295 var element = $('<form name="myForm" ng-submit="submitted = true"></form>' );
298 296
299 _.compile(element); 297 _.compile(element);
300 scope.$apply(); 298 scope.apply();
301 299
302 _.rootScope.submitted = false; 300 _.rootScope.context['submitted'] = false;
303 301
304 Event submissionEvent = new Event.eventType('CustomEvent', 'submit'); 302 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
305 element[0].dispatchEvent(submissionEvent); 303 element[0].dispatchEvent(submissionEvent);
306 304
307 expect(_.rootScope.submitted).toBe(true); 305 expect(_.rootScope.context['submitted']).toBe(true);
306 }));
307
308 it('should apply the valid and invalid prefixed submit CSS classes to the el ement', inject((TestBed _) {
309 _.compile('<form name="superForm">' +
310 ' <input type="text" ng-model="myModel" probe="i" required />' +
311 '</form>');
312
313 NgForm form = _.rootScope.context['superForm'];
314 Probe probe = _.rootScope.context['i'];
315 var model = probe.directive(NgModel);
316
317 expect(form.submitted).toBe(false);
318 expect(form.valid_submit).toBe(false);
319 expect(form.invalid_submit).toBe(false);
320 expect(form.element.classes.contains('ng-submit-invalid')).toBe(false);
321 expect(form.element.classes.contains('ng-submit-valid')).toBe(false);
322
323 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
324
325 form.element.dispatchEvent(submissionEvent);
326 _.rootScope.apply();
327
328 expect(form.submitted).toBe(true);
329 expect(form.valid_submit).toBe(false);
330 expect(form.invalid_submit).toBe(true);
331 expect(form.element.classes.contains('ng-submit-invalid')).toBe(true);
332 expect(form.element.classes.contains('ng-submit-valid')).toBe(false);
333
334 _.rootScope.apply('myModel = "man"');
335 form.element.dispatchEvent(submissionEvent);
336
337 expect(form.submitted).toBe(true);
338 expect(form.valid_submit).toBe(true);
339 expect(form.invalid_submit).toBe(false);
340 expect(form.element.classes.contains('ng-submit-invalid')).toBe(false);
341 expect(form.element.classes.contains('ng-submit-valid')).toBe(true);
308 })); 342 }));
309 }); 343 });
344
345 describe('reset()', () {
346 it('should reset the model value to its original state', inject((TestBed _) {
347 _.compile('<form name="superForm">' +
348 ' <input type="text" ng-model="myModel" probe="i" />' +
349 '</form>');
350 _.rootScope.apply('myModel = "animal"');
351
352 NgForm form = _.rootScope.context['superForm'];
353
354 Probe probe = _.rootScope.context['i'];
355 var model = probe.directive(NgModel);
356
357 expect(_.rootScope.context['myModel']).toEqual('animal');
358 expect(model.modelValue).toEqual('animal');
359 expect(model.viewValue).toEqual('animal');
360
361 _.rootScope.apply('myModel = "man"');
362
363 expect(_.rootScope.context['myModel']).toEqual('man');
364 expect(model.modelValue).toEqual('man');
365 expect(model.viewValue).toEqual('man');
366
367 form.reset();
368 _.rootScope.apply();
369
370 expect(_.rootScope.context['myModel']).toEqual('animal');
371 expect(model.modelValue).toEqual('animal');
372 expect(model.viewValue).toEqual('animal');
373 }));
374
375 it('should set the form control to be untouched when the model is reset or s ubmitted', inject((TestBed _) {
376 var form = _.compile('<form name="duperForm">' +
377 ' <input type="text" ng-model="myModel" probe="i" />' +
378 '</form>');
379 var model = _.rootScope.context['i'].directive(NgModel);
380 var input = model.element;
381
382 NgForm formModel = _.rootScope.context['duperForm'];
383
384 expect(formModel.touched).toBe(false);
385 expect(formModel.untouched).toBe(true);
386 expect(form.classes.contains('ng-touched')).toBe(false);
387 expect(form.classes.contains('ng-untouched')).toBe(true);
388
389 _.triggerEvent(input, 'blur');
390
391 expect(formModel.touched).toBe(true);
392 expect(formModel.untouched).toBe(false);
393 expect(form.classes.contains('ng-touched')).toBe(true);
394 expect(form.classes.contains('ng-untouched')).toBe(false);
395
396 formModel.reset();
397
398 expect(formModel.touched).toBe(false);
399 expect(formModel.untouched).toBe(true);
400 expect(form.classes.contains('ng-touched')).toBe(false);
401 expect(form.classes.contains('ng-untouched')).toBe(true);
402
403 _.triggerEvent(input, 'blur');
404
405 expect(formModel.touched).toBe(true);
406
407 _.triggerEvent(form, 'submit');
408
409 expect(formModel.touched).toBe(false);
410 expect(formModel.untouched).toBe(true);
411 expect(form.classes.contains('ng-touched')).toBe(false);
412 expect(form.classes.contains('ng-untouched')).toBe(true);
413 }));
414 });
415
416 describe('regression tests: form', () {
417 it('should be resolvable by injector if configured by user.', () {
418 module((Module module) {
419 module.type(NgForm);
420 });
421
422 inject((Injector injector, Compiler compiler, DirectiveMap directives) {
423 var element = $('<form></form>');
424 compiler(element, directives)(injector, element);
425 // The only expectation is that this doesn't throw
426 });
427 });
428 });
310 }); 429 });
OLDNEW
« no previous file with comments | « third_party/pkg/angular/test/directive/ng_events_spec.dart ('k') | third_party/pkg/angular/test/directive/ng_if_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698