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

Side by Side Diff: third_party/pkg/angular/test/directive/ng_form_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 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 it('should set the name of the form and attach it to the scope', inject((Scope scope, TestBed _) { 9 beforeEach(inject((TestBed tb) => _ = tb));
10
11 it('should set the name of the form and attach it to the scope', inject((Scope scope) {
10 var element = $('<form name="myForm"></form>'); 12 var element = $('<form name="myForm"></form>');
11 13
12 expect(scope.context['myForm']).toBeNull(); 14 expect(scope['myForm']).toBeNull();
13 15
14 _.compile(element); 16 _.compile(element);
15 scope.apply(); 17 scope.$apply();
16 18
17 expect(scope.context['myForm']).toBeDefined(); 19 expect(scope['myForm']).toBeDefined();
18 20
19 var form = scope.context['myForm']; 21 var form = scope['myForm'];
20 expect(form.name).toEqual('myForm'); 22 expect(form.name).toEqual('myForm');
21 })); 23 }));
22 24
23 describe('pristine / dirty', () { 25 describe('pristine / dirty', () {
24 it('should be set to pristine by default', inject((Scope scope, TestBed _) { 26 it('should be set to pristine by default', inject((Scope scope) {
25 var element = $('<form name="myForm"></form>'); 27 var element = $('<form name="myForm"></form>');
26 28
27 _.compile(element); 29 _.compile(element);
28 scope.apply(); 30 scope.$apply();
29 31
30 var form = scope.context['myForm']; 32 var form = scope['myForm'];
31 expect(form.pristine).toEqual(true); 33 expect(form.pristine).toEqual(true);
32 expect(form.dirty).toEqual(false); 34 expect(form.dirty).toEqual(false);
33 })); 35 }));
34 36
35 it('should add and remove the correct CSS classes when set to dirty and to p ristine', inject((Scope scope, TestBed _) { 37 it('should add and remove the correct CSS classes when set to dirty and to p ristine', inject((Scope scope) {
36 var element = $('<form name="myForm"></form>'); 38 var element = $('<form name="myForm"></form>');
37 39
38 _.compile(element); 40 _.compile(element);
39 scope.apply(); 41 scope.$apply();
40 42
41 var form = scope.context['myForm']; 43 var form = scope['myForm'];
42 44
43 form.dirty = true; 45 form.dirty = true;
44 expect(form.pristine).toEqual(false); 46 expect(form.pristine).toEqual(false);
45 expect(form.dirty).toEqual(true); 47 expect(form.dirty).toEqual(true);
46 expect(element.hasClass('ng-pristine')).toBe(false); 48 expect(element.hasClass('ng-pristine')).toBe(false);
47 expect(element.hasClass('ng-dirty')).toBe(true); 49 expect(element.hasClass('ng-dirty')).toBe(true);
48 50
49 form.pristine = true; 51 form.pristine = true;
50 expect(form.pristine).toEqual(true); 52 expect(form.pristine).toEqual(true);
51 expect(form.dirty).toEqual(false); 53 expect(form.dirty).toEqual(false);
52 expect(element.hasClass('ng-pristine')).toBe(true); 54 expect(element.hasClass('ng-pristine')).toBe(true);
53 expect(element.hasClass('ng-dirty')).toBe(false); 55 expect(element.hasClass('ng-dirty')).toBe(false);
54 })); 56 }));
55 }); 57 });
56 58
57 describe('valid / invalid', () { 59 describe('valid / invalid', () {
58 it('should add and remove the correct flags when set to valid and to invalid ', inject((Scope scope, TestBed _) { 60 it('should add and remove the correct flags when set to valid and to invalid ', inject((Scope scope) {
59 var element = $('<form name="myForm"></form>'); 61 var element = $('<form name="myForm"></form>');
60 62
61 _.compile(element); 63 _.compile(element);
62 scope.apply(); 64 scope.$apply();
63 65
64 var form = scope.context['myForm']; 66 var form = scope['myForm'];
65 67
66 form.invalid = true; 68 form.invalid = true;
67 expect(form.valid).toEqual(false); 69 expect(form.valid).toEqual(false);
68 expect(form.invalid).toEqual(true); 70 expect(form.invalid).toEqual(true);
69 expect(element.hasClass('ng-valid')).toBe(false); 71 expect(element.hasClass('ng-valid')).toBe(false);
70 expect(element.hasClass('ng-invalid')).toBe(true); 72 expect(element.hasClass('ng-invalid')).toBe(true);
71 73
72 form.valid = true; 74 form.valid = true;
73 expect(form.valid).toEqual(true); 75 expect(form.valid).toEqual(true);
74 expect(form.invalid).toEqual(false); 76 expect(form.invalid).toEqual(false);
75 expect(element.hasClass('ng-invalid')).toBe(false); 77 expect(element.hasClass('ng-invalid')).toBe(false);
76 expect(element.hasClass('ng-valid')).toBe(true); 78 expect(element.hasClass('ng-valid')).toBe(true);
77 })); 79 }));
78 80
79 it('should set the validity with respect to all existing validations when se tValidity() is used', inject((Scope scope, TestBed _) { 81 it('should set the validity with respect to all existing validations when se tValidity() is used', inject((Scope scope) {
80 var element = $('<form name="myForm">' 82 var element = $('<form name="myForm">' +
81 ' <input type="text" ng-model="one" name="one" />' + 83 ' <input type="text" ng-model="one" name="one" />' +
82 ' <input type="text" ng-model="two" name="two" />' + 84 ' <input type="text" ng-model="two" name="two" />' +
83 ' <input type="text" ng-model="three" name="three" />' + 85 ' <input type="text" ng-model="three" name="three" />' +
84 '</form>'); 86 '</form>');
85 87
86 _.compile(element); 88 _.compile(element);
87 scope.apply(); 89 scope.$apply();
88 90
89 var form = scope.context['myForm']; 91 var form = scope['myForm'];
90 NgModel one = form['one']; 92 NgModel one = form['one'];
91 NgModel two = form['two']; 93 NgModel two = form['two'];
92 NgModel three = form['three']; 94 NgModel three = form['three'];
93 95
94 form.updateControlValidity(one, "some error", false); 96 form.setValidity(one, "some error", false);
95 expect(form.valid).toBe(false); 97 expect(form.valid).toBe(false);
96 expect(form.invalid).toBe(true); 98 expect(form.invalid).toBe(true);
97 99
98 form.updateControlValidity(two, "some error", false); 100 form.setValidity(two, "some error", false);
99 expect(form.valid).toBe(false); 101 expect(form.valid).toBe(false);
100 expect(form.invalid).toBe(true); 102 expect(form.invalid).toBe(true);
101 103
102 form.updateControlValidity(one, "some error", true); 104 form.setValidity(one, "some error", true);
103 expect(form.valid).toBe(false); 105 expect(form.valid).toBe(false);
104 expect(form.invalid).toBe(true); 106 expect(form.invalid).toBe(true);
105 107
106 form.updateControlValidity(two, "some error", true); 108 form.setValidity(two, "some error", true);
107 expect(form.valid).toBe(true); 109 expect(form.valid).toBe(true);
108 expect(form.invalid).toBe(false); 110 expect(form.invalid).toBe(false);
109 })); 111 }));
110 112
111 it('should not handle the control errorType pair more than once', inject((Sc ope scope, TestBed _) { 113 it('should not handle the control + errorType pair more than once', inject(( Scope scope) {
112 var element = $('<form name="myForm">' 114 var element = $('<form name="myForm">' +
113 ' <input type="text" ng-model="one" name="one" />' + 115 ' <input type="text" ng-model="one" name="one" />' +
114 '</form>'); 116 '</form>');
115 117
116 _.compile(element); 118 _.compile(element);
117 scope.apply(); 119 scope.$apply();
118 120
119 var form = scope.context['myForm']; 121 var form = scope['myForm'];
120 NgModel one = form['one']; 122 NgModel one = form['one'];
121 123
122 form.updateControlValidity(one, "validation error", false); 124 form.setValidity(one, "validation error", false);
123 expect(form.valid).toBe(false); 125 expect(form.valid).toBe(false);
124 expect(form.invalid).toBe(true); 126 expect(form.invalid).toBe(true);
125 127
126 form.updateControlValidity(one, "validation error", false); 128 form.setValidity(one, "validation error", false);
127 expect(form.valid).toBe(false); 129 expect(form.valid).toBe(false);
128 expect(form.invalid).toBe(true); 130 expect(form.invalid).toBe(true);
129 131
130 form.updateControlValidity(one, "validation error", true); 132 form.setValidity(one, "validation error", true);
131 expect(form.valid).toBe(true); 133 expect(form.valid).toBe(true);
132 expect(form.invalid).toBe(false); 134 expect(form.invalid).toBe(false);
133 })); 135 }));
134 136
135 it('should update the validity of the parent form when the inner model chang es', inject((Scope scope, TestBed _) { 137 it('should update the validity of the parent form when the inner model chang es', inject((Scope scope) {
136 var element = $('<form name="myForm">' 138 var element = $('<form name="myForm">' +
137 ' <input type="text" ng-model="one" name="one" />' + 139 ' <input type="text" ng-model="one" name="one" />' +
138 ' <input type="text" ng-model="two" name="two" />' + 140 ' <input type="text" ng-model="two" name="two" />' +
139 '</form>'); 141 '</form>');
140 142
141 _.compile(element); 143 _.compile(element);
142 scope.apply(); 144 scope.$apply();
143 145
144 var form = scope.context['myForm']; 146 var form = scope['myForm'];
145 NgModel one = form['one']; 147 NgModel one = form['one'];
146 NgModel two = form['two']; 148 NgModel two = form['two'];
147 149
148 one.setValidity("required", false); 150 one.setValidity("required", false);
149 expect(form.valid).toBe(false); 151 expect(form.valid).toBe(false);
150 expect(form.invalid).toBe(true); 152 expect(form.invalid).toBe(true);
151 153
152 two.setValidity("required", false); 154 two.setValidity("required", false);
153 expect(form.valid).toBe(false); 155 expect(form.valid).toBe(false);
154 expect(form.invalid).toBe(true); 156 expect(form.invalid).toBe(true);
155 157
156 one.setValidity("required", true); 158 one.setValidity("required", true);
157 expect(form.valid).toBe(false); 159 expect(form.valid).toBe(false);
158 expect(form.invalid).toBe(true); 160 expect(form.invalid).toBe(true);
159 161
160 two.setValidity("required", true); 162 two.setValidity("required", true);
161 expect(form.valid).toBe(true); 163 expect(form.valid).toBe(true);
162 expect(form.invalid).toBe(false); 164 expect(form.invalid).toBe(false);
163 })); 165 }));
164 166
165 it('should set the validity for the parent form when fieldsets are used', in ject((Scope scope, TestBed _) { 167 it('should set the validity for the parent form when fieldsets are used', in ject((Scope scope) {
166 var element = $('<form name="myForm">' 168 var element = $('<form name="myForm">' +
167 ' <fieldset probe="f">' + 169 ' <fieldset probe="f">' +
168 ' <input type="text" ng-model="one" name="one" probe="m " />' + 170 ' <input type="text" ng-model="one" name="one" probe="m " />' +
169 ' </fieldset>' + 171 ' </fieldset>' +
170 '</form>'); 172 '</form>');
171 173
172 _.compile(element); 174 _.compile(element);
173 scope.apply(); 175 scope.$apply();
174 176
175 var form = scope.context['myForm']; 177 var form = scope['myForm'];
176 var fieldset = _.rootScope.context['f'].directive(NgForm); 178 var fieldset = _.rootScope.f.directive(NgForm);
177 var model = _.rootScope.context['m'].directive(NgModel); 179 var model = _.rootScope.m.directive(NgModel);
178 180
179 model.setValidity("error", false); 181 model.setValidity("error", false);
180 182
181 expect(model.valid).toBe(false); 183 expect(model.valid).toBe(false);
182 expect(fieldset.valid).toBe(false); 184 expect(fieldset.valid).toBe(false);
183 expect(form.valid).toBe(false); 185 expect(form.valid).toBe(false);
184 186
185 model.setValidity("error", true); 187 model.setValidity("error", true);
186 188
187 expect(model.valid).toBe(true); 189 expect(model.valid).toBe(true);
188 expect(fieldset.valid).toBe(true); 190 expect(fieldset.valid).toBe(true);
189 expect(form.valid).toBe(true); 191 expect(form.valid).toBe(true);
190 192
191 form.updateControlValidity(fieldset, "error", false); 193 form.setValidity(fieldset, "error", false);
192 expect(model.valid).toBe(true); 194 expect(model.valid).toBe(true);
193 expect(fieldset.valid).toBe(true); 195 expect(fieldset.valid).toBe(true);
194 expect(form.valid).toBe(false); 196 expect(form.valid).toBe(false);
195 197
196 fieldset.updateControlValidity(model, "error", false); 198 fieldset.setValidity(model, "error", false);
197 expect(model.valid).toBe(true); 199 expect(model.valid).toBe(true);
198 expect(fieldset.valid).toBe(false); 200 expect(fieldset.valid).toBe(false);
199 expect(form.valid).toBe(false); 201 expect(form.valid).toBe(false);
200 })); 202 }));
201 }); 203 });
202 204
203 describe('controls', () { 205 describe('controls', () {
204 it('should add each contained ng-model as a control upon compile', inject((S cope scope, TestBed _) { 206 it('should add each contained ng-model as a control upon compile', inject((S cope scope) {
205 var element = $('<form name="myForm">' 207 var element = $('<form name="myForm">' +
206 ' <input type="text" ng-model="mega_model" name="mega_nam e" />' + 208 ' <input type="text" ng-model="mega_model" name="mega_nam e" />' +
207 ' <select ng-model="fire_model" name="fire_name">' + 209 ' <select ng-model="fire_model" name="fire_name">' +
208 ' <option>value</option>' 210 ' <option>value</option>' +
209 ' </select>' + 211 ' </select>' +
210 '</form>'); 212 '</form>');
211 213
212 _.compile(element); 214 _.compile(element);
213 215
214 scope.context['mega_model'] = 'mega'; 216 scope.mega_model = 'mega';
215 scope.context['fire_model'] = 'fire'; 217 scope.fire_model = 'fire';
216 scope.apply(); 218 scope.$apply();
217 219
218 var form = scope.context['myForm']; 220 var form = scope['myForm'];
219 expect(form['mega_name'].modelValue).toBe('mega'); 221 expect(form['mega_name'].modelValue).toBe('mega');
220 expect(form['fire_name'].modelValue).toBe('fire'); 222 expect(form['fire_name'].modelValue).toBe('fire');
221 })); 223 }));
222 224
223 it('should properly remove controls directly from the ngForm instance', inje ct((Scope scope, TestBed _) { 225 it('should properly remove controls directly from the ngForm instance', inje ct((Scope scope) {
224 var element = $('<form name="myForm">' 226 var element = $('<form name="myForm">' +
225 ' <input type="text" ng-model="mega_model" name="mega_con trol" />' + 227 ' <input type="text" ng-model="mega_model" name="mega_con trol" />' +
226 '</form>'); 228 '</form>');
227 229
228 _.compile(element); 230 _.compile(element);
229 scope.apply(); 231 scope.$apply();
230 232
231 var form = scope.context['myForm']; 233 var form = scope['myForm'];
232 var control = form['mega_control']; 234 var control = form['mega_control'];
233 form.removeControl(control); 235 form.removeControl(control);
234 expect(form['mega_control']).toBeNull(); 236 expect(form['mega_control']).toBeNull();
235 })); 237 }));
236 238
237 it('should remove all controls when the scope is destroyed', inject((Scope s cope, TestBed _) { 239 it('should remove all controls when the scope is destroyed', inject((Scope s cope) {
238 Scope childScope = scope.createChild({}); 240 Scope childScope = scope.$new();
239 var element = $('<form name="myForm">' + 241 var element = $('<form name="myForm">' +
240 ' <input type="text" ng-model="one" name="one" />' + 242 ' <input type="text" ng-model="one" name="one" />' +
241 ' <input type="text" ng-model="two" name="two" />' + 243 ' <input type="text" ng-model="two" name="two" />' +
242 ' <input type="text" ng-model="three" name="three" />' + 244 ' <input type="text" ng-model="three" name="three" />' +
243 '</form>'); 245 '</form>');
244 246
245 _.compile(element, scope: childScope); 247 _.compile(element, scope: childScope);
246 childScope.apply(); 248 childScope.$apply();
247 249
248 var form = childScope.context['myForm']; 250 var form = childScope['myForm'];
249 expect(form['one']).toBeDefined(); 251 expect(form['one']).toBeDefined();
250 expect(form['two']).toBeDefined(); 252 expect(form['two']).toBeDefined();
251 expect(form['three']).toBeDefined(); 253 expect(form['three']).toBeDefined();
252 254
253 childScope.destroy(); 255 childScope.$destroy();
254 256
255 expect(form['one']).toBeNull(); 257 expect(form['one']).toBeNull();
256 expect(form['two']).toBeNull(); 258 expect(form['two']).toBeNull();
257 expect(form['three']).toBeNull(); 259 expect(form['three']).toBeNull();
258 })); 260 }));
259 }); 261 });
260 262
261 describe('onSubmit', () { 263 describe('onSubmit', () {
262 it('should suppress the submission event if no action is provided within the form', inject((Scope scope, TestBed _) { 264 it('should suppress the submission event if no action is provided within the form', inject((Scope scope) {
263 var element = $('<form name="myForm"></form>'); 265 var element = $('<form name="myForm"></form>');
264 266
265 _.compile(element); 267 _.compile(element);
266 scope.apply(); 268 scope.$apply();
267 269
268 Event submissionEvent = new Event.eventType('CustomEvent', 'submit'); 270 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
269 271
270 expect(submissionEvent.defaultPrevented).toBe(false); 272 expect(submissionEvent.defaultPrevented).toBe(false);
271 element[0].dispatchEvent(submissionEvent); 273 element[0].dispatchEvent(submissionEvent);
272 expect(submissionEvent.defaultPrevented).toBe(true); 274 expect(submissionEvent.defaultPrevented).toBe(true);
273 275
274 Event fakeEvent = new Event.eventType('CustomEvent', 'running'); 276 Event fakeEvent = new Event.eventType('CustomEvent', 'running');
275 277
276 expect(fakeEvent.defaultPrevented).toBe(false); 278 expect(fakeEvent.defaultPrevented).toBe(false);
277 element[0].dispatchEvent(submissionEvent); 279 element[0].dispatchEvent(submissionEvent);
278 expect(fakeEvent.defaultPrevented).toBe(false); 280 expect(fakeEvent.defaultPrevented).toBe(false);
279 })); 281 }));
280 282
281 it('should not prevent the submission event if an action is defined', inject ((Scope scope, TestBed _) { 283 it('should not prevent the submission event if an action is defined', inject ((Scope scope) {
282 var element = $('<form name="myForm" action="..."></form>'); 284 var element = $('<form name="myForm" action="..."></form>');
283 285
284 _.compile(element); 286 _.compile(element);
285 scope.apply(); 287 scope.$apply();
286 288
287 Event submissionEvent = new Event.eventType('CustomEvent', 'submit'); 289 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
288 290
289 expect(submissionEvent.defaultPrevented).toBe(false); 291 expect(submissionEvent.defaultPrevented).toBe(false);
290 element[0].dispatchEvent(submissionEvent); 292 element[0].dispatchEvent(submissionEvent);
291 expect(submissionEvent.defaultPrevented).toBe(false); 293 expect(submissionEvent.defaultPrevented).toBe(false);
292 })); 294 }));
293 295
294 it('should execute the ng-submit expression if provided upon form submission ', inject((Scope scope, TestBed _) { 296 it('should execute the ng-submit expression if provided upon form submission ', inject((Scope scope) {
295 var element = $('<form name="myForm" ng-submit="submitted = true"></form>' ); 297 var element = $('<form name="myForm" ng-submit="submitted = true"></form>' );
296 298
297 _.compile(element); 299 _.compile(element);
298 scope.apply(); 300 scope.$apply();
299 301
300 _.rootScope.context['submitted'] = false; 302 _.rootScope.submitted = false;
301 303
302 Event submissionEvent = new Event.eventType('CustomEvent', 'submit'); 304 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
303 element[0].dispatchEvent(submissionEvent); 305 element[0].dispatchEvent(submissionEvent);
304 306
305 expect(_.rootScope.context['submitted']).toBe(true); 307 expect(_.rootScope.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);
342 })); 308 }));
343 }); 309 });
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 });
429 }); 310 });
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