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_icon_test; | 5 library polymer_elements.test.iron_icon_test; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:js'; | 8 import 'dart:js'; |
9 import 'package:polymer_elements/iron_icon.dart'; | 9 import 'package:polymer_elements/iron_icon.dart'; |
10 import 'package:polymer_elements/iron_iconset.dart'; | 10 import 'package:polymer_elements/iron_iconset.dart'; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 test('can change its icon dynamically', () { | 63 test('can change its icon dynamically', () { |
64 var style = icon.style; | 64 var style = icon.style; |
65 expect( | 65 expect( |
66 style.backgroundPosition, contains(new RegExp(r'0(%|px) 0(%|px)'))); | 66 style.backgroundPosition, contains(new RegExp(r'0(%|px) 0(%|px)'))); |
67 icon.icon = "example:blank"; | 67 icon.icon = "example:blank"; |
68 expect( | 68 expect( |
69 style.backgroundPosition, contains(new RegExp(r'-24px 0(%|px)'))); | 69 style.backgroundPosition, contains(new RegExp(r'-24px 0(%|px)'))); |
70 }); | 70 }); |
71 }); | 71 }); |
| 72 |
72 group('when no icon source is provided', () { | 73 group('when no icon source is provided', () { |
73 test('will politely wait for an icon source without throwing', () { | 74 test('will politely wait for an icon source without throwing', () { |
74 document.createElement('iron-icon'); | 75 document.createElement('iron-icon'); |
75 fixture('WithoutAnIconSource'); | 76 fixture('WithoutAnIconSource'); |
76 }); | 77 }); |
77 }); | 78 }); |
| 79 |
| 80 group('when loading async', () { |
| 81 test('will get icon after iconset is added', () { |
| 82 var icon = fixture('UsingAsyncIconset'); |
| 83 expect(hasIcon(icon), isFalse); |
| 84 |
| 85 var done = window.on['iron-iconset-added'].first.then((_) { |
| 86 expect(hasIcon(icon), isTrue, |
| 87 reason: 'icon didn\'t load after iconset loaded'); |
| 88 }); |
| 89 fixture('AsyncIconset'); |
| 90 |
| 91 return done; |
| 92 }); |
| 93 }); |
78 }); | 94 }); |
79 } | 95 } |
OLD | NEW |