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

Side by Side Diff: third_party/polymer/v0_8/components-chromium/iron-selector/test/basic.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-basic</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
30 .my-selected {
31 background: red;
32 }
33 </style>
34
35 </head>
36 <body>
37
38 <test-fixture id="defaults">
39 <template>
40 <iron-selector>
41 <div>Item 0</div>
42 <div>Item 1</div>
43 <div>Item 2</div>
44 <div>Item 3</div>
45 <div>Item 4</div>
46 </iron-selector>
47 </template>
48 </test-fixture>
49
50 <br><br>
51
52 <test-fixture id="basic">
53 <template>
54 <iron-selector selected="item2" attr-for-selected="id">
55 <div id="item0">Item 0</div>
56 <div id="item1">Item 1</div>
57 <div id="item2">Item 2</div>
58 <div id="item3">Item 3</div>
59 <div id="item4">Item 4</div>
60 </iron-selector>
61 </template>
62 </test-fixture>
63
64 <script>
65
66 suite('defaults', function() {
67
68 var s1;
69
70 setup(function () {
71 s1 = fixture('defaults');
72 });
73
74 test('to nothing selected', function() {
75 assert.equal(s1.selected, null);
76 });
77
78 test('to iron-selected as selectedClass', function() {
79 assert.equal(s1.selectedClass, 'iron-selected');
80 });
81
82 test('to false as multi', function() {
83 assert.isFalse(s1.multi);
84 });
85
86 test('to click as activateEvent', function() {
87 assert.equal(s1.activateEvent, 'click');
88 });
89
90 test('to nothing as attrForSelected', function() {
91 assert.equal(s1.attrForSelected, null);
92 });
93
94 test('as many items as children', function() {
95 assert.equal(s1.items.length, s1.querySelectorAll('div').length);
96 });
97 });
98
99 suite('basic', function() {
100
101 var s2;
102
103 setup(function () {
104 s2 = fixture('basic');
105 });
106
107 test('honors the attrForSelected attribute', function() {
108 assert.equal(s2.attrForSelected, 'id');
109 assert.equal(s2.selected, 'item2');
110 assert.equal(s2.selectedItem, document.querySelector('#item2'));
111 });
112
113 test('allows assignment to selected', function() {
114 // set selected
115 s2.selected = 'item4';
116 // check selected class
117 assert.isTrue(s2.children[4].classList.contains('iron-selected'));
118 // check item
119 assert.equal(s2.selectedItem, s2.children[4]);
120 });
121
122 test('fire iron-select when selected is set', function() {
123 // setup listener for iron-select event
124 var selectedEventCounter = 0;
125 s2.addEventListener('iron-select', function(e) {
126 selectedEventCounter++;
127 });
128 // set selected
129 s2.selected = 'item4';
130 // check iron-select event
131 assert.equal(selectedEventCounter, 1);
132 });
133
134 test('set selected to old value', function() {
135 // setup listener for iron-select event
136 var selectedEventCounter = 0;
137 s2.addEventListener('iron-select', function(e) {
138 selectedEventCounter++;
139 });
140 // selecting the same value shouldn't fire iron-select
141 s2.selected = 'item2';
142 assert.equal(selectedEventCounter, 0);
143 });
144
145 });
146
147 </script>
148
149 </body>
150 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698