OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @TestOn('browser') | 4 @TestOn('browser') |
5 library polymer_elements.test.iron_iconset_test; | 5 library polymer_elements.test.iron_iconset_test; |
6 | 6 |
| 7 import 'dart:html'; |
| 8 import 'package:polymer_interop/polymer_interop.dart'; |
7 import 'package:polymer_elements/iron_iconset.dart'; | 9 import 'package:polymer_elements/iron_iconset.dart'; |
8 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
9 import 'package:web_components/web_components.dart'; | 11 import 'package:web_components/web_components.dart'; |
10 import 'common.dart'; | 12 import 'common.dart'; |
11 | 13 |
12 /// Used imports: [IronIconset] | 14 /// Used imports: [IronIconset] |
13 main() async { | 15 main() async { |
14 await initWebComponents(); | 16 await initWebComponents(); |
15 | 17 |
16 group('<iron-iconset>', () { | 18 group('<iron-iconset>', () { |
17 group('basic behavior', () { | 19 group('basic behavior', () { |
18 var iconset; | 20 var iconset; |
19 var meta; | 21 var meta; |
20 | 22 |
21 setUp(() { | 23 setUp(() { |
22 var elements = fixture('TrivialIconset'); | 24 var elements = fixture('TrivialIconset'); |
23 iconset = elements[0]; | 25 iconset = elements[0]; |
24 meta = elements[1]; | 26 meta = elements[1]; |
25 }); | 27 }); |
26 | 28 |
27 test('it can be accessed via iron-meta', () { | 29 test('it can be accessed via iron-meta', () { |
28 expect(meta.byKey('foo'), iconset); | 30 expect(meta.byKey('foo'), iconset); |
29 }); | 31 }); |
| 32 |
| 33 test('it fires an iron-iconset-added event on the window', () { |
| 34 return window.on['iron-iconset-added'].first.then((ev) { |
| 35 ev = convertToDart(ev); |
| 36 expect(ev, isNotNull); |
| 37 expect(ev.detail, iconset); |
| 38 }); |
| 39 }); |
30 }); | 40 }); |
31 group('when src, width, iconSize and icons are assigned', () { | 41 group('when src, width, iconSize and icons are assigned', () { |
32 var iconset; | 42 var iconset; |
33 var div; | 43 var div; |
34 | 44 |
35 setUp(() { | 45 setUp(() { |
36 var elements = fixture('StandardIconset'); | 46 var elements = fixture('StandardIconset'); |
37 iconset = elements[0]; | 47 iconset = elements[0]; |
38 div = elements[1]; | 48 div = elements[1]; |
39 }); | 49 }); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 test('adjusts the icon by the theme offset', () { | 88 test('adjusts the icon by the theme offset', () { |
79 var iconStyle; | 89 var iconStyle; |
80 iconset.applyIcon(div, 'bus', 'large', null); | 90 iconset.applyIcon(div, 'bus', 'large', null); |
81 iconStyle = div.getComputedStyle(); | 91 iconStyle = div.getComputedStyle(); |
82 expect( | 92 expect( |
83 iconStyle.backgroundPosition, contains(new RegExp(r'-10px -34px'))); | 93 iconStyle.backgroundPosition, contains(new RegExp(r'-10px -34px'))); |
84 }); | 94 }); |
85 }); | 95 }); |
86 }); | 96 }); |
87 } | 97 } |
OLD | NEW |