update components

This commit is contained in:
Luke Pulverenti 2016-01-06 11:38:19 -05:00
parent 46ceec311d
commit 89c9a7b669
38 changed files with 1530 additions and 316 deletions

View file

@ -1,14 +1,11 @@
<!doctype html>
<!--
<!DOCTYPE html><!--
Copyright (c) 2014 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
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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>iron-input ests</title>
@ -18,7 +15,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script>
WCT.loadSuites([
'iron-input.html',
'iron-input.html?dom=shadow'
]);
</script>
</body>
</html>
</body></html>

View file

@ -44,19 +44,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<test-fixture id="prevent-invalid-input">
<template>
<input is="iron-input" prevent-invalid-input pattern="[0-9]">
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]">
</template>
</test-fixture>
<test-fixture id="prevent-invalid-input-with-pattern">
<template>
<input is="iron-input" prevent-invalid-input pattern="[a-zA-Z]{3}[0-9]*">
</template>
</test-fixture>
<test-fixture id="prevent-invalid-input-has-value">
<template>
<input is="iron-input" prevent-invalid-input pattern="[0-9]*" value="foobar">
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]" value="foobar">
</template>
</test-fixture>
<test-fixture id="prevent-invalid-input-has-bind-value">
<template>
<input is="iron-input" prevent-invalid-input pattern="[0-9]*" bind-value="foobar">
<input is="iron-input" prevent-invalid-input allowed-pattern="[0-9]" bind-value="foobar">
</template>
</test-fixture>
@ -66,6 +72,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</template>
</test-fixture>
<test-fixture id="no-validator">
<template>
<input is="iron-input" pattern="[a-zA-Z]{3}[0-9]*">
</template>
</test-fixture>
<test-fixture id="has-validator">
<template>
<letters-only></letters-only>
@ -116,6 +128,26 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.ok(!scope.$.input.value, 'value is falsy');
});
test('can validate using a complex regex', function() {
var input = fixture('no-validator');
input.value = '123';
input.validate();
assert.isTrue(input.invalid, 'input is invalid');
input.value = 'foo';
input.validate();
assert.isFalse(input.invalid, 'input is valid');
input.value = 'foo123';
input.validate();
assert.isFalse(input.invalid, 'input is valid');
});
test('set bindValue to false', function() {
var scope = document.getElementById('bind-to-object');
scope.foo = false;
assert.isFalse(scope.$.input.bindValue);
assert.equal(scope.$.input.value, 'false');
});
test('validator used instead of constraints api if provided', function() {
var input = fixture('has-validator')[1];
input.value = '123';
@ -134,6 +166,27 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(input.bindValue, '123');
});
test('inputs can be validated', function() {
var input = fixture('prevent-invalid-input-with-pattern');
input.value = '123';
input._onInput();
assert.equal(input.bindValue, '123');
input.validate();
assert.isTrue(input.invalid, 'input is invalid');
input.value = 'foo';
input._onInput();
assert.equal(input.bindValue, 'foo');
input.validate();
assert.isFalse(input.invalid, 'input is valid');
input.value = 'foo123';
input._onInput();
assert.equal(input.bindValue, 'foo123');
input.validate();
assert.isFalse(input.invalid, 'input is valid');
});
test('prevent invalid input works automatically when allowed pattern is set', function() {
var input = fixture('automatically-prevent-invalid-input-if-allowed-pattern');
input.value = '123';