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

Unified 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, 12 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 side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/directive/ng_form_spec.dart
diff --git a/third_party/pkg/angular/test/directive/ng_form_spec.dart b/third_party/pkg/angular/test/directive/ng_form_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a957b735810358801e048f9d2d8973b4f6b4c21a
--- /dev/null
+++ b/third_party/pkg/angular/test/directive/ng_form_spec.dart
@@ -0,0 +1,56 @@
+library form_spec;
+
+import '../_specs.dart';
+
+main() =>
+describe('form', () {
+ TestBed _;
+
+ beforeEach(inject((TestBed tb) => _ = tb));
+
+ it('should suppress the submission event if no action is provided within the form', inject((Scope scope) {
+ var element = $('<form name="myForm"></form>');
+
+ _.compile(element);
+ scope.$apply();
+
+ Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
+
+ expect(submissionEvent.defaultPrevented).toBe(false);
+ element[0].dispatchEvent(submissionEvent);
+ expect(submissionEvent.defaultPrevented).toBe(true);
+
+ Event fakeEvent = new Event.eventType('CustomEvent', 'running');
+
+ expect(fakeEvent.defaultPrevented).toBe(false);
+ element[0].dispatchEvent(submissionEvent);
+ expect(fakeEvent.defaultPrevented).toBe(false);
+ }));
+
+ it('should not prevent the submission event if an action is defined', inject((Scope scope) {
+ var element = $('<form name="myForm" action="..."></form>');
+
+ _.compile(element);
+ scope.$apply();
+
+ Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
+
+ expect(submissionEvent.defaultPrevented).toBe(false);
+ element[0].dispatchEvent(submissionEvent);
+ expect(submissionEvent.defaultPrevented).toBe(false);
+ }));
+
+ it('should execute the ng-submit expression if provided upon form submission', inject((Scope scope) {
+ var element = $('<form name="myForm" ng-submit="submitted = true"></form>');
+
+ _.compile(element);
+ scope.$apply();
+
+ _.rootScope.submitted = false;
+
+ Event submissionEvent = new Event.eventType('CustomEvent', 'submit');
+ element[0].dispatchEvent(submissionEvent);
+
+ expect(_.rootScope.submitted).toBe(true);
+ }));
+});

Powered by Google App Engine
This is Rietveld 408576698