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

Unified Diff: polymer_1.0.4/bower_components/paper-input/test/paper-input-container.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: polymer_1.0.4/bower_components/paper-input/test/paper-input-container.html
diff --git a/polymer_1.0.4/bower_components/paper-input/test/paper-input-container.html b/polymer_1.0.4/bower_components/paper-input/test/paper-input-container.html
new file mode 100644
index 0000000000000000000000000000000000000000..0b7acf87c8003c256aa35de82d99dd59d0f63f2c
--- /dev/null
+++ b/polymer_1.0.4/bower_components/paper-input/test/paper-input-container.html
@@ -0,0 +1,237 @@
+<!doctype html>
+<!--
+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
+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>
+
+ <title>paper-input-container tests</title>
+
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
+
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
+
+ <script src="../../web-component-tester/browser.js"></script>
+ <script src="../../test-fixture/test-fixture-mocha.js"></script>
+
+ <link rel="import" href="../../test-fixture/test-fixture.html">
+ <link rel="import" href="../../iron-input/iron-input.html">
+ <link rel="import" href="../paper-input-container.html">
+ <link rel="import" href="letters-only.html">
+
+</head>
+<body>
+
+ <test-fixture id="basic">
+ <template>
+ <paper-input-container>
+ <label id="l">label</label>
+ <input id="i">
+ </paper-input-container>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="has-value">
+ <template>
+ <paper-input-container>
+ <label id="l">label</label>
+ <input id="i" value="value">
+ </paper-input-container>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="no-float-has-value">
+ <template>
+ <paper-input-container no-label-float>
+ <label id="l">label</label>
+ <input id="i" value="value">
+ </paper-input-container>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="always-float">
+ <template>
+ <paper-input-container always-float-label>
+ <label id="l">label</label>
+ <input id="i" value="value">
+ </paper-input-container>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="auto-validate-numbers">
+ <template>
+ <paper-input-container auto-validate>
+ <label id="l">label</label>
+ <input is="iron-input" id="i" pattern="[0-9]*">
+ </paper-input-container>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="manual-validate-numbers">
+ <template>
+ <paper-input-container>
+ <label id="l">label</label>
+ <input is="iron-input" id="i" pattern="[0-9]*">
+ </paper-input-container>
+ </template>
+ </test-fixture>
+
+ <letters-only></letters-only>
+
+ <test-fixture id="auto-validate-validator">
+ <template>
+ <paper-input-container auto-validate>
+ <label id="l">label</label>
+ <input is="iron-input" id="i" pattern="[0-9]*" validator="letters-only">
+ </paper-input-container>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="auto-validate-validator-has-invalid-value">
+ <template>
+ <paper-input-container auto-validate>
+ <label id="l">label</label>
+ <input is="iron-input" id="i" validator="letters-only" value="123123">
+ </paper-input-container>
+ </template>
+ </test-fixture>
+
+ <script>
+
+ function getTransform(node) {
+ var style = getComputedStyle(node);
+ return style.transform || style.webkitTransform;
+ }
+
+ suite('label position', function() {
+
+ test('label is visible by default', function() {
+ var container = fixture('basic');
+ assert.equal(getComputedStyle(container.querySelector('#l')).visibility, 'visible', 'label has visibility:visible');
+ });
+
+ test('label is floated if value is initialized to not null', function() {
+ var container = fixture('has-value');
+ assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform');
+ });
+
+ test('label is invisible if no-label-float and value is initialized to not null', function() {
+ var container = fixture('no-float-has-value');
+ assert.equal(getComputedStyle(container.querySelector('#l')).visibility, 'hidden', 'label has visibility:hidden');
+ });
+
+ test('label is floated if always-float-label is true', function() {
+ var container = fixture('always-float');
+ assert.notEqual(getTransform(container.querySelector('#l')), 'none', 'label has transform');
+ })
+
+ });
+
+ suite('focused styling', function() {
+
+ test('label is colored when input is focused and has value', function(done) {
+ var container = fixture('has-value');
+ var label = Polymer.dom(container).querySelector('#l');
+ var input = Polymer.dom(container).querySelector('#i');
+ var inputContent = Polymer.dom(container.root).querySelector('.input-content');
+ input.focus();
+ // 'focus' event isn't firing on windows ff for some reason when you call focus()
+ container._onFocus();
+ requestAnimationFrame(function() {
+ assert.equal(document.activeElement, input, 'input is focused');
+ assert.isTrue(container.focused, 'focused is true');
+ assert.isTrue(inputContent.classList.contains('label-is-highlighted'), 'label is highlighted when input has focus');
+ done();
+ });
+ });
+
+ test('label is not colored when input is focused and has null value', function(done) {
+ var container = fixture('basic');
+ var label = Polymer.dom(container).querySelector('#l');
+ var input = Polymer.dom(container).querySelector('#i');
+ var inputContent = Polymer.dom(container.root).querySelector('.input-content');
+ input.focus();
+ container._onFocus();
+ requestAnimationFrame(function() {
+ assert.isFalse(inputContent.classList.contains('label-is-highlighted'), 'label is not highlighted when input has focus and has null value');
+ done();
+ });
+ });
+
+ test('underline is colored when input is focused', function(done) {
+ var container = fixture('basic');
+ var input = Polymer.dom(container).querySelector('#i');
+ var line = Polymer.dom(container.root).querySelector('.underline');
+ assert.isFalse(line.classList.contains('is-highlighted'), 'line is not highlighted when input is not focused');
+ input.focus();
+ container._onFocus();
+ requestAnimationFrame(function() {
+ assert.equal(document.activeElement, input, 'input is focused');
+ assert.isTrue(line.classList.contains('is-highlighted'), 'line is highlighted when input is focused');
+ done();
+ });
+ });
+
+ });
+
+ suite('validation', function() {
+
+ test('styled when the input is set to an invalid value with auto-validate', function() {
+ var container = fixture('auto-validate-numbers');
+ var input = Polymer.dom(container).querySelector('#i');
+ var inputContent = Polymer.dom(container.root).querySelector('.input-content');
+ var line = Polymer.dom(container.root).querySelector('.underline');
+
+ input.bindValue = 'foobar';
+
+ assert.isTrue(container.invalid, 'invalid is true');
+ assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
+ assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
+ });
+
+ test('styled when the input is set to an invalid value with auto-validate, with validator', function() {
+ var container = fixture('auto-validate-validator');
+ var input = Polymer.dom(container).querySelector('#i');
+ var inputContent = Polymer.dom(container.root).querySelector('.input-content');
+ var line = Polymer.dom(container.root).querySelector('.underline');
+
+ input.bindValue = '123123';
+
+ assert.isTrue(container.invalid, 'invalid is true');
+ assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
+ assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
+ });
+
+ test('styled when the input is set initially to an invalid value with auto-validate, with validator', function() {
+ var container = fixture('auto-validate-validator-has-invalid-value');
+ assert.isTrue(container.invalid, 'invalid is true');
+ assert.isTrue(Polymer.dom(container.root).querySelector('.underline').classList.contains('is-invalid'), 'underline has is-invalid class');
+ });
+
+ test('styled when the input is set to an invalid value with manual validation', function() {
+ var container = fixture('manual-validate-numbers');
+ var input = Polymer.dom(container).querySelector('#i');
+ var inputContent = Polymer.dom(container.root).querySelector('.input-content');
+ var line = Polymer.dom(container.root).querySelector('.underline');
+
+ input.bindValue = 'foobar';
+ input.validate();
+
+ assert.isTrue(container.invalid, 'invalid is true');
+ assert.isTrue(inputContent.classList.contains('is-invalid'), 'label has invalid styling when input is invalid');
+ assert.isTrue(line.classList.contains('is-invalid'), 'underline has invalid styling when input is invalid');
+ });
+
+ });
+
+ </script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698