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

Side by Side Diff: third_party/polymer/v0_8/components-chromium/iron-selector/test/template-repeat.html

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rerun reproduce.sh Created 5 years, 7 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 <script src="../../test-fixture/test-fixture-mocha.js"></script>
21
22 <link rel="import" href="../../test-fixture/test-fixture.html">
23 <link rel="import" href="../iron-selector.html">
24
25 <style>
26 .iron-selected {
27 background: #ccc;
28 }
29 </style>
30
31 </head>
32 <body>
33
34 <test-fixture id="test">
35 <template>
36 <iron-selector id="selector" selected="1">
37 <template id="t" is="x-repeat">
38 <div id$="[[item.name]]">{{item.name}}</div>
39 </template>
40 </iron-selector>
41 </template>
42 </test-fixture>
43
44 <script>
45
46 suite('x-repeat', function() {
47
48 var s, t;
49
50 setup(function () {
51 s = fixture('test');
52 t = s.querySelector('#t');
53 });
54
55 test('supports repeated items', function(done) {
56 t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'ite m3'}];
57 setTimeout(function() {
58 // check items
59 assert.equal(s.items.length, 4);
60 // check selected
61 assert.equal(s.selected, 1);
62 // check selected item
63 var item = s.selectedItem;
64 assert.equal(s.items[1], item);
65 // check selected class
66 assert.isTrue(item.classList.contains('iron-selected'));
67 done();
68 });
69 });
70
71 test('update items', function(done) {
72 t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'ite m3'}];
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 t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'ite m3'}];
94 setTimeout(function() {
95 // set selected to something else
96 s.selected = 3;
97 // check selected item
98 var item = s.selectedItem;
99 assert.equal(s.items[3], item);
100 // check selected class
101 assert.isTrue(item.classList.contains('iron-selected'));
102 done();
103 });
104 });
105
106 });
107
108 </script>
109
110 </body>
111 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698