| OLD | NEW |
| 1 library ng_events_spec; | 1 library ng_events_spec; |
| 2 | 2 |
| 3 import '../_specs.dart'; | 3 import '../_specs.dart'; |
| 4 import 'dart:html' as dom; | 4 import 'dart:html' as dom; |
| 5 | 5 |
| 6 void addTest(String name, [String eventType='MouseEvent', String eventName, excl
usive=false]) { | 6 void addTest(String name, [String eventType='MouseEvent', String eventName]) { |
| 7 if (eventName == null) { | 7 if (eventName == null) { |
| 8 eventName = name; | 8 eventName = name; |
| 9 } | 9 } |
| 10 | 10 |
| 11 var describeBody = () { | 11 describe('ng-$name', () { |
| 12 TestBed _; | 12 TestBed _; |
| 13 | 13 |
| 14 beforeEach((TestBed tb) => _ = tb); | 14 beforeEach(inject((TestBed tb) => _ = tb)); |
| 15 | 15 |
| 16 it('should evaluate the expression on $name', () { | 16 it('should evaluate the expression on $name', inject(() { |
| 17 _.compile('<button ng-$name="abc = true; event = \$event"></button>'); | 17 _.compile('<button ng-$name="abc = true; event = \$event"></button>'); |
| 18 _.triggerEvent(_.rootElement, eventName, eventType); | 18 _.triggerEvent(_.rootElement, eventName, eventType); |
| 19 expect(_.rootScope.context['abc']).toEqual(true); | 19 expect(_.rootScope.context['abc']).toEqual(true); |
| 20 expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true); | 20 expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true); |
| 21 }); | 21 })); |
| 22 }; | 22 }); |
| 23 | |
| 24 if (exclusive) { | |
| 25 ddescribe('ng-$name', describeBody); | |
| 26 } else { | |
| 27 describe('ng-$name', describeBody); | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 void aaddTest(String name, [String eventType='MouseEvent', String eventName]) { | |
| 32 addTest(name, eventType, eventName, true); | |
| 33 } | 23 } |
| 34 | 24 |
| 35 main() { | 25 main() { |
| 36 addTest('abort'); | 26 addTest('abort'); |
| 37 addTest('beforecopy'); | 27 addTest('beforecopy'); |
| 38 addTest('beforecopy'); | 28 addTest('beforecopy'); |
| 39 addTest('beforecut'); | 29 addTest('beforecut'); |
| 40 addTest('beforepaste'); | 30 addTest('beforepaste'); |
| 41 addTest('blur'); | 31 addTest('blur'); |
| 42 addTest('change'); | 32 addTest('change'); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 //addTest('speechchange'); | 70 //addTest('speechchange'); |
| 81 addTest('submit'); | 71 addTest('submit'); |
| 82 // These should be of type TouchEvent but that causes the tests to fail. | 72 // These should be of type TouchEvent but that causes the tests to fail. |
| 83 // They pass as a MouseEvent. | 73 // They pass as a MouseEvent. |
| 84 //addTest('touchcancel'/*, 'TouchEvent'*/); | 74 //addTest('touchcancel'/*, 'TouchEvent'*/); |
| 85 addTest('touchenter'/*, 'TouchEvent'*/); | 75 addTest('touchenter'/*, 'TouchEvent'*/); |
| 86 addTest('touchleave'/*, 'TouchEvent'*/); | 76 addTest('touchleave'/*, 'TouchEvent'*/); |
| 87 addTest('touchend'/*, 'TouchEvent'*/); | 77 addTest('touchend'/*, 'TouchEvent'*/); |
| 88 addTest('touchmove'/*, 'TouchEvent'*/); | 78 addTest('touchmove'/*, 'TouchEvent'*/); |
| 89 addTest('touchstart'/*, 'TouchEvent'*/); | 79 addTest('touchstart'/*, 'TouchEvent'*/); |
| 90 // Disabled due to http://dartbug.com/17990 | 80 addTest('transitionend'); |
| 91 //addTest('transitionend'); | |
| 92 } | 81 } |
| OLD | NEW |