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

Side by Side Diff: polymer_1.0.4/bower_components/iron-selector/test/template-repeat.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 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
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
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
9 -->
10
11 <html>
12 <head>
13
14 <title>iron-selector-template-repeat</title>
15 <meta charset="utf-8">
16 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum- scale=1.0">
17
18 <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
19 <script src="../../web-component-tester/browser.js"></script>
20
21 <link rel="import" href="../iron-selector.html">
22
23 <style>
24 .iron-selected {
25 background: #ccc;
26 }
27 </style>
28
29 </head>
30 <body>
31
32 <template is="dom-bind">
33 <iron-selector id="selector" selected="1">
34 <template id="t" is="dom-repeat">
35 <div id$="[[item.name]]">{{item.name}}</div>
36 </template>
37 </iron-selector>
38 </template>
39
40 <script>
41
42 suite('dom-repeat', function() {
43
44 var scope, s, t;
45
46 setup(function() {
47 scope = document.querySelector('template[is="dom-bind"]');
48 s = scope.$.selector;
49 t = scope.$.t;
50 t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'ite m3'}];
51 });
52
53 teardown(function() {
54 t.items = [];
55 });
56
57 test('supports repeated items', function(done) {
58 setTimeout(function() {
59 // check items
60 assert.equal(s.items.length, 4);
61 // check selected
62 assert.equal(s.selected, 1);
63 // check selected item
64 var item = s.selectedItem;
65 assert.equal(s.items[1], item);
66 // check selected class
67 assert.isTrue(item.classList.contains('iron-selected'));
68 done();
69 });
70 });
71
72 test('update items', function(done) {
73 setTimeout(function() {
74 // check items
75 assert.equal(s.items.length, 4);
76 // check selected
77 assert.equal(s.selected, 1);
78 // update items
79 t.items = [{name:'foo'}, {name: 'bar'}];
80 setTimeout(function() {
81 // check items
82 assert.equal(s.items.length, 2);
83 // check selected (should still honor the selected)
84 assert.equal(s.selected, 1);
85 // check selected class
86 assert.isTrue(s.querySelector('#bar').classList.contains('iron-selec ted'));
87 done();
88 });
89 });
90 });
91
92 test('set selected to something else', function(done) {
93 setTimeout(function() {
94 // set selected to something else
95 s.selected = 3;
96 // check selected item
97 var item = s.selectedItem;
98 assert.equal(s.items[3], item);
99 // check selected class
100 assert.isTrue(item.classList.contains('iron-selected'));
101 done();
102 });
103 });
104
105 });
106
107 </script>
108
109 </body>
110 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698