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

Side by Side Diff: polymer_1.0.4/bower_components/iron-icon/test/iron-icon.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <!--
3 @license
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
8 Code distributed by Google as part of the polymer project is also
9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
10 -->
11
12 <html>
13 <head>
14
15 <title>iron-icon</title>
16 <meta charset="utf-8">
17 <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
19 <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
20 <script src="../../web-component-tester/browser.js"></script>
21 <script src="../../test-fixture/test-fixture-mocha.js"></script>
22
23 <link rel="import" href="../iron-icon.html">
24 <link rel="import" href="../../iron-iconset/iron-iconset.html">
25 <link rel="import" href="../../test-fixture/test-fixture.html">
26
27 </head>
28 <body>
29
30 <test-fixture id="TrivialIcon">
31 <template>
32 <iron-icon src="../demo/location.png"></iron-icon>
33 </template>
34 </test-fixture>
35
36 <test-fixture id="IconFromIconset">
37 <template>
38 <iron-iconset name="example" icons="location blank" src="location.png" siz e="24" width="48"></iron-iconset>
39 <iron-icon icon="example:location"></iron-icon>
40 </template>
41 </test-fixture>
42
43 <test-fixture id="WithoutAnIconSource">
44 <template>
45 <iron-icon icon=""></iron-icon>
46 <iron-icon></iron-icon>
47 <iron-icon src=""></iron-icon>
48 </template>
49 </test-fixture>
50
51 <script>
52 function iconElementFor (node) {
53 var nodes = Polymer.dom(node.root).childNodes;
54
55 for (var i = 0; i < nodes.length; ++i) {
56 if (nodes[i].nodeName.match(/DIV|IMG/)) {
57 return nodes[i];
58 }
59 }
60 }
61
62 function hasIcon (node) {
63 return /png/.test(node.style.backgroundImage);
64 }
65
66 suite('<iron-icon>', function() {
67 suite('basic behavior', function() {
68 var icon;
69
70 setup(function() {
71 icon = fixture('TrivialIcon');
72 });
73
74 test('can be assigned an icon with the src attribute', function() {
75 expect(iconElementFor(icon)).to.be.ok;
76 expect(iconElementFor(icon).src).to.match(/demo\/location\.png/);
77 });
78
79 test('can change its src dynamically', function() {
80 icon.src = 'foo.png';
81
82 expect(iconElementFor(icon).src).to.match(/foo\.png/);
83 });
84 });
85
86 suite('when paired with an iconset', function() {
87 var icon;
88
89 setup(function() {
90 var elements = fixture('IconFromIconset');
91
92 icon = elements[1];
93 });
94
95 test('can be assigned an icon from the iconset', function() {
96 expect(hasIcon(icon)).to.be.ok;
97 });
98
99 test('can change its icon dynamically', function() {
100 var style = icon.style;
101
102 expect(style.backgroundPosition).to.match(/0(%|px) 0(%|px)/);
103
104 icon.icon = "example:blank";
105
106 expect(style.backgroundPosition).to.match(/-24px 0(%|px)/);
107 });
108 });
109
110 suite('when no icon source is provided', function() {
111 test('will politely wait for an icon source without throwing', function() {
112 document.createElement('iron-icon');
113 fixture('WithoutAnIconSource');
114 });
115 })
116 });
117 </script>
118
119 </body>
120 </html>
OLDNEW
« no previous file with comments | « polymer_1.0.4/bower_components/iron-icon/test/index.html ('k') | polymer_1.0.4/bower_components/iron-icons/.bower.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698