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

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

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
(Empty)
1 library form_spec;
2
3 import '../_specs.dart';
4
5 main() =>
6 describe('form', () {
7 TestBed _;
8
9 beforeEach(inject((TestBed tb) => _ = tb));
10
11 it('should suppress the submission event if no action is provided within the f orm', inject((Scope scope) {
12 var element = $('<form name="myForm"></form>');
13
14 _.compile(element);
15 scope.$apply();
16
17 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
18
19 expect(submissionEvent.defaultPrevented).toBe(false);
20 element[0].dispatchEvent(submissionEvent);
21 expect(submissionEvent.defaultPrevented).toBe(true);
22
23 Event fakeEvent = new Event.eventType('CustomEvent', 'running');
24
25 expect(fakeEvent.defaultPrevented).toBe(false);
26 element[0].dispatchEvent(submissionEvent);
27 expect(fakeEvent.defaultPrevented).toBe(false);
28 }));
29
30 it('should not prevent the submission event if an action is defined', inject(( Scope scope) {
31 var element = $('<form name="myForm" action="..."></form>');
32
33 _.compile(element);
34 scope.$apply();
35
36 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
37
38 expect(submissionEvent.defaultPrevented).toBe(false);
39 element[0].dispatchEvent(submissionEvent);
40 expect(submissionEvent.defaultPrevented).toBe(false);
41 }));
42
43 it('should execute the ng-submit expression if provided upon form submission', inject((Scope scope) {
44 var element = $('<form name="myForm" ng-submit="submitted = true"></form>');
45
46 _.compile(element);
47 scope.$apply();
48
49 _.rootScope.submitted = false;
50
51 Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
52 element[0].dispatchEvent(submissionEvent);
53
54 expect(_.rootScope.submitted).toBe(true);
55 }));
56 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698