| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library polymer.test.web.custom_event_test; | 5 library polymer.test.web.custom_event_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:polymer/polymer.dart'; | 9 import 'package:polymer/polymer.dart'; |
| 10 import 'package:template_binding/template_binding.dart' show nodeBind; |
| 10 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 11 import 'package:unittest/html_config.dart'; | 12 import 'package:unittest/html_config.dart'; |
| 12 | 13 |
| 13 | 14 |
| 14 @CustomTag('foo-bar') | 15 @CustomTag('foo-bar') |
| 15 class FooBar extends PolymerElement { | 16 class FooBar extends PolymerElement { |
| 16 // A little too much boilerplate? | 17 // A little too much boilerplate? |
| 17 static const EventStreamProvider<CustomEvent> fooEvent = | 18 static const EventStreamProvider<CustomEvent> fooEvent = |
| 18 const EventStreamProvider<CustomEvent>('foo'); | 19 const EventStreamProvider<CustomEvent>('foo'); |
| 19 static const EventStreamProvider<CustomEvent> barBazEvent = | 20 static const EventStreamProvider<CustomEvent> barBazEvent = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 | 44 |
| 44 main() { | 45 main() { |
| 45 initPolymer(); | 46 initPolymer(); |
| 46 useHtmlConfiguration(); | 47 useHtmlConfiguration(); |
| 47 | 48 |
| 48 setUp(() => Polymer.onReady); | 49 setUp(() => Polymer.onReady); |
| 49 | 50 |
| 50 test('custom event', () { | 51 test('custom event', () { |
| 51 final testComp = query('test-custom-event'); | 52 final testComp = query('test-custom-event'); |
| 52 final fooBar = testComp.fooBar; | 53 final fooBar = testComp.fooBar; |
| 54 |
| 55 final binding = nodeBind(fooBar).bindings['on-barbaz']; |
| 56 expect(binding, isNotNull, reason: 'on-barbaz event should be bound'); |
| 57 |
| 58 expect(binding.model is! StreamSubscription, true, |
| 59 reason: 'event bindings should not be a StreamSubscription'); |
| 60 |
| 53 fooBar.fireFoo(123); | 61 fooBar.fireFoo(123); |
| 54 fooBar.fireBarBaz(42); | 62 fooBar.fireBarBaz(42); |
| 55 fooBar.fireFoo(777); | 63 fooBar.fireFoo(777); |
| 56 | 64 |
| 57 final events = testComp.events; | 65 final events = testComp.events; |
| 58 expect(events.length, 3); | 66 expect(events.length, 3); |
| 59 expect(events.map((e) => e[0]), ['foo', 'barbaz', 'foo']); | 67 expect(events.map((e) => e[0]), ['foo', 'barbaz', 'foo']); |
| 60 expect(events.map((e) => e[1].detail), [123, 42, 777]); | 68 expect(events.map((e) => e[1].detail), [123, 42, 777]); |
| 61 }); | 69 }); |
| 62 } | 70 } |
| OLD | NEW |