OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 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 <html> |
| 11 <head> |
| 12 |
| 13 <title>paper-input tests</title> |
| 14 |
| 15 <meta charset="utf-8"> |
| 16 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 17 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initia
l-scale=1, user-scalable=yes"> |
| 18 |
| 19 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 20 |
| 21 <script src="../../web-component-tester/browser.js"></script> |
| 22 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 23 |
| 24 <script src="../../iron-test-helpers/test-helpers.js"></script> |
| 25 |
| 26 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 27 <link rel="import" href="../paper-input.html"> |
| 28 |
| 29 </head> |
| 30 <body> |
| 31 |
| 32 <test-fixture id="basic"> |
| 33 <template> |
| 34 <paper-input></paper-input> |
| 35 </template> |
| 36 </test-fixture> |
| 37 |
| 38 <test-fixture id="error"> |
| 39 <template> |
| 40 <paper-input auto-validate pattern="[0-9]*" value="foobar" error-message="
error"></paper-input> |
| 41 </template> |
| 42 </test-fixture> |
| 43 |
| 44 <test-fixture id="required"> |
| 45 <template> |
| 46 <paper-input auto-validate required error-message="error"></paper-input> |
| 47 </template> |
| 48 </test-fixture> |
| 49 |
| 50 <test-fixture id="char-counter"> |
| 51 <template> |
| 52 <paper-input char-counter value="foobar"></paper-input> |
| 53 </template> |
| 54 </test-fixture> |
| 55 |
| 56 <script> |
| 57 |
| 58 suite('basic', function() { |
| 59 |
| 60 test('setting value sets the input value', function() { |
| 61 var input = fixture('basic'); |
| 62 input.value = 'foobar'; |
| 63 assert.equal(input.inputElement.value, input.value, 'inputElement.value
equals input.value'); |
| 64 }); |
| 65 |
| 66 test('error message is displayed', function() { |
| 67 var input = fixture('error'); |
| 68 forceXIfStamp(input); |
| 69 var error = Polymer.dom(input.root).querySelector('paper-input-error'); |
| 70 assert.ok(error, 'paper-input-error exists'); |
| 71 assert.notEqual(getComputedStyle(error).display, 'none', 'error is not d
isplay:none'); |
| 72 }); |
| 73 |
| 74 test('empty required input shows error', function() { |
| 75 var input = fixture('required'); |
| 76 var error = Polymer.dom(input.root).querySelector('paper-input-error'); |
| 77 assert.ok(error, 'paper-input-error exists'); |
| 78 assert.notEqual(getComputedStyle(error).display, 'none', 'error is not d
isplay:none'); |
| 79 }); |
| 80 |
| 81 test('character counter is displayed', function() { |
| 82 var input = fixture('char-counter'); |
| 83 forceXIfStamp(input); |
| 84 var counter = Polymer.dom(input.root).querySelector('paper-input-char-co
unter') |
| 85 assert.ok(counter, 'paper-input-char-counter exists'); |
| 86 assert.equal(counter.charCounter, input.value.length, 'character counter
shows the value length'); |
| 87 }); |
| 88 |
| 89 }); |
| 90 |
| 91 </script> |
| 92 |
| 93 </body> |
| 94 </html> |
OLD | NEW |