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

Side by Side Diff: polymer_1.2.3/bower_components/paper-item/test/paper-item.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
(Empty)
1 <!--
2 @license
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 <!doctype html>
11 <html>
12 <head>
13
14 <title>paper-item tests</title>
15
16 <meta charset="utf-8">
17 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
18 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initia l-scale=1, user-scalable=yes">
19
20 <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
21
22 <script src="../../web-component-tester/browser.js"></script>
23 <script src="../../iron-test-helpers/mock-interactions.js"></script>
24
25 <link rel="import" href="../../paper-input/paper-input.html">
26 <link rel="import" href="../paper-item.html">
27 <link rel="import" href="../paper-icon-item.html">
28
29 </head>
30 <body>
31
32 <test-fixture id="item">
33 <template>
34 <div role="listbox">
35 <paper-item>item</paper-item>
36 </div>
37 </template>
38 </test-fixture>
39
40 <test-fixture id="iconItem">
41 <template>
42 <div role="listbox">
43 <paper-icon-item>item</paper-icon-item>
44 </div>
45 </template>
46 </test-fixture>
47
48 <test-fixture id="item-with-input">
49 <template>
50 <div role="list">
51 <paper-item><input></paper-item>
52 </div>
53 </template>
54 </test-fixture>
55
56 <test-fixture id="item-with-paper-input">
57 <template>
58 <div role="list">
59 <paper-item><paper-input></paper-input></paper-item>
60 </div>
61 </template>
62 </test-fixture>
63
64 <test-fixture id="iconItem-with-input">
65 <template>
66 <div role="list">
67 <paper-icon-item><input></paper-icon-item>
68 </div>
69 </template>
70 </test-fixture>
71
72 <script>
73 suite('paper-item basic', function() {
74 var item, clickHandler;
75
76 setup(function() {
77 item = fixture('item').querySelector('paper-item');
78 clickHandler = sinon.spy();
79 item.addEventListener('click', clickHandler);
80 });
81
82 test('space triggers a click event', function(done) {
83 MockInteractions.pressSpace(item);
84 Polymer.Base.async(function(){
85 // You need two ticks, one for the MockInteractions event, and one
86 // for the button event.
87 Polymer.Base.async(function(){
88 expect(clickHandler.callCount).to.be.equal(1);
89 done();
90 }, 1);
91 }, 1);
92 });
93
94 test('click triggers a click event', function(done) {
95 MockInteractions.tap(item);
96 Polymer.Base.async(function(){
97 expect(clickHandler.callCount).to.be.equal(1);
98 done();
99 }, 1);
100 });
101 });
102
103 suite('paper-icon-item basic', function() {
104 var item, clickHandler;
105
106 setup(function() {
107 item = fixture('iconItem').querySelector('paper-icon-item');
108 clickHandler = sinon.spy();
109 item.addEventListener('click', clickHandler);
110 });
111
112 test('space triggers a click event', function(done) {
113 MockInteractions.pressSpace(item);
114 Polymer.Base.async(function(){
115 // You need two ticks, one for the MockInteractions event, and one
116 // for the button event.
117 Polymer.Base.async(function(){
118 expect(clickHandler.callCount).to.be.equal(1);
119 done();
120 }, 1);
121 }, 1);
122 });
123
124 test('click triggers a click event', function(done) {
125 MockInteractions.tap(item);
126 Polymer.Base.async(function(){
127 expect(clickHandler.callCount).to.be.equal(1);
128 done();
129 }, 1);
130 });
131 });
132
133 suite('clickable element inside item', function() {
134 test('paper-item: space in child native input does not trigger a click e vent', function(done) {
135 var f = fixture('item-with-input');
136 var outerItem = f.querySelector('paper-item');
137 var innerInput = f.querySelector('input');
138
139 var itemClickHandler = sinon.spy();
140 outerItem.addEventListener('click', itemClickHandler);
141
142 innerInput.focus();
143 MockInteractions.pressSpace(innerInput);
144 Polymer.Base.async(function(){
145 expect(itemClickHandler.callCount).to.be.equal(0);
146 done();
147 }, 1);
148 });
149
150 test('paper-item: space in child paper-input does not trigger a click ev ent', function(done) {
151 var f = fixture('item-with-paper-input');
152 var outerItem = f.querySelector('paper-item');
153 var innerInput = f.querySelector('paper-input');
154
155 var itemClickHandler = sinon.spy();
156 outerItem.addEventListener('click', itemClickHandler);
157
158 innerInput.focus();
159 MockInteractions.pressSpace(innerInput);
160 Polymer.Base.async(function(){
161 expect(itemClickHandler.callCount).to.be.equal(0);
162 done();
163 }, 1);
164 });
165
166 test('paper-icon-item: space in child input does not trigger a click eve nt', function(done) {
167 var f = fixture('iconItem-with-input');
168 var outerItem = f.querySelector('paper-icon-item');
169 var innerInput = f.querySelector('input');
170
171 var itemClickHandler = sinon.spy();
172 outerItem.addEventListener('click', itemClickHandler);
173
174 MockInteractions.pressSpace(innerInput);
175 Polymer.Base.async(function(){
176 expect(itemClickHandler.callCount).to.be.equal(0);
177 done();
178 }, 1);
179 });
180 });
181
182 suite('item a11y tests', function() {
183 var item, iconItem;
184
185 setup(function() {
186 item = fixture('item').querySelector('paper-item');
187 iconItem = fixture('iconItem').querySelector('paper-icon-item');
188 });
189
190 test('item has role="listitem"', function() {
191 assert.equal(item.getAttribute('role'), 'option', 'has role="option"') ;
192 });
193
194 test('icon item has role="listitem"', function() {
195 assert.equal(iconItem.getAttribute('role'), 'option', 'has role="optio n"');
196 });
197
198 a11ySuite('item');
199 a11ySuite('iconItem');
200 });
201
202 </script>
203
204 </body>
205 </html>
OLDNEW
« no previous file with comments | « polymer_1.2.3/bower_components/paper-item/test/index.html ('k') | polymer_1.2.3/bower_components/paper-material/.bower.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698