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

Unified Diff: polymer_1.0.4/bower_components/paper-input/test/paper-input.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.html
diff --git a/polymer_1.0.4/bower_components/paper-input/test/paper-input.html b/polymer_1.0.4/bower_components/paper-input/test/paper-input.html
new file mode 100644
index 0000000000000000000000000000000000000000..1c4dc25a3a7ef63c740c9c8a0e200bf5dba01269
--- /dev/null
+++ b/polymer_1.0.4/bower_components/paper-input/test/paper-input.html
@@ -0,0 +1,244 @@
+<!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 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>
+
+ <script src="../../iron-test-helpers/test-helpers.js"></script>
+
+ <link rel="import" href="../../test-fixture/test-fixture.html">
+ <link rel="import" href="../paper-input.html">
+ <link rel="import" href="letters-only.html">
+
+</head>
+<body>
+
+ <test-fixture id="basic">
+ <template>
+ <paper-input></paper-input>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="label">
+ <template>
+ <paper-input label="foo"></paper-input>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="error">
+ <template>
+ <paper-input auto-validate pattern="[0-9]*" value="foobar" error-message="error"></paper-input>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="required">
+ <template>
+ <paper-input auto-validate required error-message="error"></paper-input>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="required-no-auto-validate">
+ <template>
+ <paper-input required error-message="error"></paper-input>
+ </template>
+ </test-fixture>
+
+
+ <test-fixture id="required-char-counter">
+ <template>
+ <paper-input auto-validate char-counter required error-message="error"></paper-input>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="char-counter">
+ <template>
+ <paper-input char-counter value="foobar"></paper-input>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="always-float-label">
+ <template>
+ <paper-input always-float-label label="foo"></paper-input>
+ </template>
+ </test-fixture>
+
+ <test-fixture id="placeholder">
+ <template>
+ <paper-input label="foo" placeholder="bar"></paper-input>
+ </template>
+ </test-fixture>
+
+ <letters-only></letters-only>
+
+ <test-fixture id="validator">
+ <template>
+ <paper-input value="123123" validator="letters-only" auto-validate></paper-input>
+ </template>
+ </test-fixture>
+
+ <script>
+
+ suite('basic', function() {
+
+ test('setting value sets the input value', function() {
+ var input = fixture('basic');
+ input.value = 'foobar';
+ assert.equal(input.inputElement.value, input.value, 'inputElement.value equals input.value');
+ });
+
+ test('placeholder does not overlap label', function() {
+ var input = fixture('placeholder');
+ assert.equal(input.inputElement.placeholder, input.placeholder, 'inputElement.placeholder equals input.placeholder');
+ assert.equal(input.noLabelFloat, false);
+ var floatingLabel = Polymer.dom(Polymer.dom(input.root).querySelector('paper-input-container').root).querySelector('.label-is-floating');
+ assert.ok(floatingLabel);
+ });
+
+ test('always-float-label attribute works without placeholder', function() {
+ var input = fixture('always-float-label');
+ var container = Polymer.dom(input.root).querySelector('paper-input-container');
+ var inputContent = Polymer.dom(container.root).querySelector('.input-content');
+ assert.isTrue(inputContent.classList.contains('label-is-floating'), 'label is floating');
+ });
+
+ test('error message is displayed', function() {
+ var input = fixture('error');
+ forceXIfStamp(input);
+ var error = Polymer.dom(input.root).querySelector('paper-input-error');
+ assert.ok(error, 'paper-input-error exists');
+ assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
+ });
+
+ test('empty required input shows error', function() {
+ var input = fixture('required');
+ forceXIfStamp(input);
+ var error = Polymer.dom(input.root).querySelector('paper-input-error');
+ assert.ok(error, 'paper-input-error exists');
+ assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
+ });
+
+ test('character counter is displayed', function() {
+ var input = fixture('char-counter');
+ forceXIfStamp(input);
+ var counter = Polymer.dom(input.root).querySelector('paper-input-char-counter')
+ assert.ok(counter, 'paper-input-char-counter exists');
+ assert.equal(counter._charCounterStr, input.value.length, 'character counter shows the value length');
+ });
+
+ test('validator is used', function() {
+ var input = fixture('validator');
+ assert.ok(input.inputElement.invalid, 'input is invalid');
+ });
+
+ test('caret position is preserved', function() {
+ var input = fixture('basic');
+ var ironInput = Polymer.dom(input.root).querySelector('input[is="iron-input"]');
+ input.value = 'nananana';
+ ironInput.selectionStart = 2;
+ ironInput.selectionEnd = 2;
+
+ input.updateValueAndPreserveCaret('nanananabatman');
+
+ assert.equal(ironInput.selectionStart, 2, 'selectionStart is preserved');
+ assert.equal(ironInput.selectionEnd, 2, 'selectionEnd is preserved');
+ });
+
+ });
+
+ suite('focus/blur events', function() {
+ var input;
+
+ setup(function() {
+ input = fixture('basic');
+ });
+
+ test('focus/blur events fired on host element', function(done) {
+ var nFocusEvents = 0;
+ var nBlurEvents = 0;
+ input.addEventListener('focus', function() {
+ nFocusEvents += 1;
+ // setTimeout to wait for potentially more, erroneous events
+ setTimeout(function() {
+ assert.equal(nFocusEvents, 1, 'one focus event fired');
+ input.inputElement.blur();
+ });
+ });
+ input.addEventListener('blur', function() {
+ nBlurEvents += 1;
+ // setTimeout to wait for potentially more, erroneous events
+ setTimeout(function() {
+ assert.equal(nBlurEvents, 1, 'one blur event fired');
+ done();
+ });
+ });
+ input.inputElement.focus();
+ });
+
+ });
+
+ suite('validation', function() {
+
+ test('invalid attribute updated after calling validate()', function() {
+ var input = fixture('required-no-auto-validate');
+ forceXIfStamp(input);
+ input.validate();
+ var error = Polymer.dom(input.root).querySelector('paper-input-error');
+ assert.ok(error, 'paper-input-error exists');
+ assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
+ assert.isTrue(input.invalid, 'invalid is true');
+ });
+
+ });
+
+ suite('a11y', function() {
+
+ test('has aria-labelledby', function() {
+ var input = fixture('label');
+ assert.isTrue(input.inputElement.hasAttribute('aria-labelledby'))
+ assert.equal(input.inputElement.getAttribute('aria-labelledby'), Polymer.dom(input.root).querySelector('label').id, 'aria-labelledby points to the label');
+ });
+
+ test('has aria-describedby for error message', function() {
+ var input = fixture('required');
+ forceXIfStamp(input);
+ assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
+ assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-error').id, 'aria-describedby points to the error message');
+ });
+
+ test('has aria-describedby for character counter', function() {
+ var input = fixture('char-counter');
+ forceXIfStamp(input);
+ assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
+ assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-char-counter').id, 'aria-describedby points to the character counter');
+ });
+
+ test('has aria-describedby for character counter and error', function() {
+ var input = fixture('required-char-counter');
+ forceXIfStamp(input);
+ assert.isTrue(input.inputElement.hasAttribute('aria-describedby'));
+ assert.equal(input.inputElement.getAttribute('aria-describedby'), Polymer.dom(input.root).querySelector('paper-input-error').id + ' ' + Polymer.dom(input.root).querySelector('paper-input-char-counter').id, 'aria-describedby points to the error message and character counter');
+ });
+
+ });
+
+ </script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698