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

Side by Side Diff: polymer_1.2.3/bower_components/iron-selector/test/basic.html

Issue 1581713003: [third_party] add polymer 1.2.3 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: 1.2.3 Created 4 years, 11 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
1 <!doctype html> 1 <!doctype html>
2 <!-- 2 <!--
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt 4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also 7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 --> 9 -->
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 }); 97 });
98 98
99 suite('basic', function() { 99 suite('basic', function() {
100 100
101 var s2; 101 var s2;
102 102
103 setup(function () { 103 setup(function () {
104 s2 = fixture('basic'); 104 s2 = fixture('basic');
105 }); 105 });
106 106
107 test('honors the attrForSelected attribute', function() { 107 test('honors the attrForSelected attribute', function(done) {
108 assert.equal(s2.attrForSelected, 'id'); 108 Polymer.Base.async(function() {
109 assert.equal(s2.selected, 'item2'); 109 assert.equal(s2.attrForSelected, 'id');
110 assert.equal(s2.selectedItem, document.querySelector('#item2')); 110 assert.equal(s2.selected, 'item2');
111 assert.equal(s2.selectedItem, document.querySelector('#item2'));
112 done();
113 });
111 }); 114 });
112 115
113 test('allows assignment to selected', function() { 116 test('allows assignment to selected', function() {
114 // set selected 117 // set selected
115 s2.selected = 'item4'; 118 s2.selected = 'item4';
116 // check selected class 119 // check selected class
117 assert.isTrue(s2.children[4].classList.contains('iron-selected')); 120 assert.isTrue(s2.children[4].classList.contains('iron-selected'));
118 // check item 121 // check item
119 assert.equal(s2.selectedItem, s2.children[4]); 122 assert.equal(s2.selectedItem, s2.children[4]);
120 }); 123 });
(...skipping 14 matching lines...) Expand all
135 // setup listener for iron-select event 138 // setup listener for iron-select event
136 var selectedEventCounter = 0; 139 var selectedEventCounter = 0;
137 s2.addEventListener('iron-select', function(e) { 140 s2.addEventListener('iron-select', function(e) {
138 selectedEventCounter++; 141 selectedEventCounter++;
139 }); 142 });
140 // selecting the same value shouldn't fire iron-select 143 // selecting the same value shouldn't fire iron-select
141 s2.selected = 'item2'; 144 s2.selected = 'item2';
142 assert.equal(selectedEventCounter, 0); 145 assert.equal(selectedEventCounter, 0);
143 }); 146 });
144 147
148 suite('items changing', function() {
149 test('cause iron-items-changed to fire', function(done) {
150 var newItem = document.createElement('div');
151 var changeCount = 0;
152
153 newItem.id = 'item999';
154
155 s2.addEventListener('iron-items-changed', function() {
156 changeCount++;
157 });
158
159 Polymer.dom(s2).appendChild(newItem);
160
161 Polymer.Base.async(function() {
162 Polymer.dom(s2).removeChild(newItem);
163
164 Polymer.Base.async(function() {
165 expect(changeCount).to.be.equal(2);
166 done();
167 }, 1);
168 }, 1);
169 });
170 });
171
172 suite('dynamic selector', function() {
173 test('selects dynamically added child automatically', function(done) {
174 var selector = document.createElement('iron-selector');
175 var child = document.createElement('div');
176
177 selector.selected = '0';
178 child.textContent = 'Item 0';
179
180 Polymer.dom(selector).appendChild(child);
181 document.body.appendChild(selector);
182
183 Polymer.Base.async(function() {
184 assert.equal(child.className, 'iron-selected');
185 document.body.removeChild(selector);
186 done();
187 }, 1);
188 });
189 });
145 }); 190 });
146 191
147 </script> 192 </script>
148 193
149 </body> 194 </body>
150 </html> 195 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698