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

Unified Diff: third_party/pkg/angular/test/directive/ng_events_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_events_spec.dart
diff --git a/third_party/pkg/angular/test/directive/ng_events_spec.dart b/third_party/pkg/angular/test/directive/ng_events_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..12be0996bb904eea7adcd9d826d927d46ee672be
--- /dev/null
+++ b/third_party/pkg/angular/test/directive/ng_events_spec.dart
@@ -0,0 +1,56 @@
+library ng_events_spec;
+
+import '../_specs.dart';
+import 'dart:html' as dom;
+
+void addTest(String name, [String eventType='MouseEvent', String eventName]) {
+ if (eventName == null) {
+ eventName = name;
+ }
+
+ describe('ng-$name', () {
+ TestBed _;
+
+ beforeEach(inject((TestBed tb) => _ = tb));
+
+ it('should evaluate the expression on $name', inject(() {
+ _.compile('<button ng-$name="abc = true; event = \$event"></button>');
+ _.triggerEvent(_.rootElement, eventName, eventType);
+ expect(_.rootScope['abc']).toEqual(true);
+ expect(_.rootScope['event'] is dom.UIEvent).toEqual(true);
+ }));
+ });
+}
+
+main() {
+ addTest('blur');
+ addTest('change');
+ addTest('click');
+ addTest('contextmenu');
+ // The event name differs from the ng- directive name.
+ addTest('doubleclick', 'MouseEvent', 'dblclick');
+ addTest('dragenter');
+ addTest('dragleave');
+ addTest('dragover');
+ addTest('dragstart');
+ addTest('drop');
+ addTest('focus');
+ addTest('keydown', 'KeyboardEvent');
+ addTest('keypress', 'KeyboardEvent');
+ addTest('keyup', 'KeyboardEvent');
+ addTest('mousedown');
+ addTest('mouseenter');
+ addTest('mouseleave');
+ addTest('mousemove');
+ addTest('mouseout');
+ addTest('mouseover');
+ addTest('mouseup');
+ addTest('mousewheel', 'MouseEvent', 'wheel');
+ addTest('scroll');
+ // These should be of type TouchEvent but that causes the tests to fail.
+ // They pass as a MouseEvent.
+ addTest('touchcancel'/*, 'TouchEvent'*/);
+ addTest('touchend'/*, 'TouchEvent'*/);
+ addTest('touchmove'/*, 'TouchEvent'*/);
+ addTest('touchstart'/*, 'TouchEvent'*/);
+}

Powered by Google App Engine
This is Rietveld 408576698