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

Unified Diff: test/iron_iconset_svg_test.dart

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 2 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
« no previous file with comments | « test/iron_icon_test.html ('k') | test/iron_iconset_svg_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/iron_iconset_svg_test.dart
diff --git a/test/iron_iconset_svg_test.dart b/test/iron_iconset_svg_test.dart
index 5d2fa2aaeccec4e84f6c945a66a195cdefff7985..c92a2ba18202b3dc50e03532ef6b1be05676cf66 100644
--- a/test/iron_iconset_svg_test.dart
+++ b/test/iron_iconset_svg_test.dart
@@ -4,7 +4,10 @@
@TestOn('browser')
library polymer_elements.test.iron_iconset_svg_test;
+import 'dart:html';
+import 'package:polymer_interop/polymer_interop.dart';
import 'package:polymer_elements/iron_iconset_svg.dart';
+import 'package:polymer_elements/iron_meta.dart';
import 'package:test/test.dart';
import 'package:web_components/web_components.dart';
import 'common.dart';
@@ -15,8 +18,8 @@ main() async {
group('<iron-iconset>', () {
group('basic behavior', () {
- var iconset;
- var meta;
+ IronIconsetSvg iconset;
+ IronMeta meta;
setUp(() {
var elements = fixture('TrivialIconsetSvg');
@@ -27,9 +30,24 @@ main() async {
test('it can be accessed via iron-meta', () {
expect(meta.byKey('foo'), iconset);
});
+
+ test('it does not have a size', () {
+ var rect = iconset.getBoundingClientRect();
+ expect(rect.width, 0);
+ expect(rect.height, 0);
+ });
+
+ test('it fires an iron-iconset-added event on the window', () {
+ return window.on['iron-iconset-added'].first.then((ev) {
+ ev = convertToDart(ev);
+ expect(ev, isNotNull);
+ expect(ev.detail, iconset);
+ });
+ });
});
+
group('when paired with a size and SVG definition', () {
- var iconset;
+ IronIconsetSvg iconset;
var div;
setUp(() {
@@ -38,6 +56,12 @@ main() async {
div = elements[1];
});
+ test('it does not have a size', () {
+ var rect = iconset.getBoundingClientRect();
+ expect(rect.width, 0);
+ expect(rect.height, 0);
+ });
+
test('appends a child to the target element', () {
expect(div.children.length, 0);
iconset.applyIcon(div, 'circle');
@@ -45,7 +69,8 @@ main() async {
});
test('can be queried for all available icons', () {
- expect(iconset.getIconNames(), ['my-icons:circle', 'my-icons:square']);
+ expect(iconset.getIconNames(),
+ ['my-icons:circle', 'my-icons:square', 'my-icons:rect']);
});
test('supports any icon defined in the svg', () {
@@ -56,6 +81,17 @@ main() async {
lastSvgIcon = div.children.first;
});
});
+
+ test('prefers a viewBox attribute over the iconset size', () {
+ iconset.applyIcon(div, 'rect');
+ expect(div.children.first.getAttribute('viewBox'), '0 0 50 25');
+ });
+
+ test('uses the iconset size when viewBox is not defined on the element',
+ () {
+ iconset.applyIcon(div, 'circle');
+ expect(div.children.first.getAttribute('viewBox'), '0 0 20 20');
+ });
});
});
}
« no previous file with comments | « test/iron_icon_test.html ('k') | test/iron_iconset_svg_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698