update polymer components

This commit is contained in:
Luke Pulverenti 2015-12-04 11:58:14 -05:00
parent 22f689e089
commit 2eb2a5011d
18 changed files with 287 additions and 104 deletions

View file

@ -1,5 +1,4 @@
<!doctype html>
<!--
<!DOCTYPE html><!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
@ -7,9 +6,7 @@ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
--><html><head>
<title>paper-item tests</title>
@ -23,12 +20,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<body>
<script>
WCT.loadSuites([
'paper-item.html'
'paper-item.html',
'paper-item.html?dom=shadow'
]);
</script>
</body>
</html>
</body></html>

View file

@ -20,9 +20,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="../../iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../paper-input/paper-input.html">
<link rel="import" href="../paper-item.html">
<link rel="import" href="../paper-icon-item.html">
@ -45,7 +45,139 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</template>
</test-fixture>
<test-fixture id="item-with-input">
<template>
<div role="list">
<paper-item><input></paper-item>
</div>
</template>
</test-fixture>
<test-fixture id="item-with-paper-input">
<template>
<div role="list">
<paper-item><paper-input></paper-input></paper-item>
</div>
</template>
</test-fixture>
<test-fixture id="iconItem-with-input">
<template>
<div role="list">
<paper-icon-item><input></paper-icon-item>
</div>
</template>
</test-fixture>
<script>
suite('paper-item basic', function() {
var item, clickHandler;
setup(function() {
item = fixture('item').querySelector('paper-item');
clickHandler = sinon.spy();
item.addEventListener('click', clickHandler);
});
test('space triggers a click event', function(done) {
MockInteractions.pressSpace(item);
Polymer.Base.async(function(){
// You need two ticks, one for the MockInteractions event, and one
// for the button event.
Polymer.Base.async(function(){
expect(clickHandler.callCount).to.be.equal(1);
done();
}, 1);
}, 1);
});
test('click triggers a click event', function(done) {
MockInteractions.tap(item);
Polymer.Base.async(function(){
expect(clickHandler.callCount).to.be.equal(1);
done();
}, 1);
});
});
suite('paper-icon-item basic', function() {
var item, clickHandler;
setup(function() {
item = fixture('iconItem').querySelector('paper-icon-item');
clickHandler = sinon.spy();
item.addEventListener('click', clickHandler);
});
test('space triggers a click event', function(done) {
MockInteractions.pressSpace(item);
Polymer.Base.async(function(){
// You need two ticks, one for the MockInteractions event, and one
// for the button event.
Polymer.Base.async(function(){
expect(clickHandler.callCount).to.be.equal(1);
done();
}, 1);
}, 1);
});
test('click triggers a click event', function(done) {
MockInteractions.tap(item);
Polymer.Base.async(function(){
expect(clickHandler.callCount).to.be.equal(1);
done();
}, 1);
});
});
suite('clickable element inside item', function() {
test('paper-item: space in child native input does not trigger a click event', function(done) {
var f = fixture('item-with-input');
var outerItem = f.querySelector('paper-item');
var innerInput = f.querySelector('input');
var itemClickHandler = sinon.spy();
outerItem.addEventListener('click', itemClickHandler);
innerInput.focus();
MockInteractions.pressSpace(innerInput);
Polymer.Base.async(function(){
expect(itemClickHandler.callCount).to.be.equal(0);
done();
}, 1);
});
test('paper-item: space in child paper-input does not trigger a click event', function(done) {
var f = fixture('item-with-paper-input');
var outerItem = f.querySelector('paper-item');
var innerInput = f.querySelector('paper-input');
var itemClickHandler = sinon.spy();
outerItem.addEventListener('click', itemClickHandler);
innerInput.focus();
MockInteractions.pressSpace(innerInput);
Polymer.Base.async(function(){
expect(itemClickHandler.callCount).to.be.equal(0);
done();
}, 1);
});
test('paper-icon-item: space in child input does not trigger a click event', function(done) {
var f = fixture('iconItem-with-input');
var outerItem = f.querySelector('paper-icon-item');
var innerInput = f.querySelector('input');
var itemClickHandler = sinon.spy();
outerItem.addEventListener('click', itemClickHandler);
MockInteractions.pressSpace(innerInput);
Polymer.Base.async(function(){
expect(itemClickHandler.callCount).to.be.equal(0);
done();
}, 1);
});
});
suite('item a11y tests', function() {
var item, iconItem;