Home | History | Annotate | Download | only in test
      1 <!doctype html>
      2 <!--
      3 @license
      4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
      5 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
      6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
      7 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
      8 Code distributed by Google as part of the polymer project is also
      9 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
     10 -->
     11 <html>
     12 <head>
     13 
     14   <title>paper-input-error tests</title>
     15 
     16   <meta charset="utf-8">
     17   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     18   <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
     19 
     20   <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
     21   <script src="../../web-component-tester/browser.js"></script>
     22 
     23   <link rel="import" href="../../iron-input/iron-input.html">
     24   <link rel="import" href="../paper-input-container.html">
     25   <link rel="import" href="../paper-input-error.html">
     26 
     27 </head>
     28 <body>
     29 
     30   <paper-input-container id="container">
     31     <input is="iron-input">
     32     <paper-input-error>error</paper-input-error>
     33   </paper-input-container>
     34 
     35   <test-fixture id="auto-validate-numbers">
     36     <template>
     37       <paper-input-container auto-validate attr-for-value="bind-value">
     38         <label id="l">label</label>
     39         <input is="iron-input" id="i" pattern="[0-9]*">
     40         <paper-input-error id="e">error</paper-input-error>
     41       </paper-input-container>
     42     </template>
     43   </test-fixture>
     44 
     45   <script>
     46 
     47     suite('basic', function() {
     48 
     49       test('error message only appears when input is invalid', function() {
     50         var container = fixture('auto-validate-numbers');
     51         var input = Polymer.dom(container).querySelector('#i');
     52         var error = Polymer.dom(container).querySelector('#e');
     53         assert.equal(getComputedStyle(error).visibility, 'hidden', 'error is visibility:hidden');
     54         input.bindValue = 'foobar';
     55         assert.notEqual(getComputedStyle(error).visibility, 'hidden', 'error is not visibility:hidden');
     56       });
     57 
     58       test('error message add on is registered', function() {
     59         var container = document.getElementById('container');
     60         assert.isTrue(container._addons && container._addons.length === 1, 'add on is registered');
     61       });
     62 
     63     });
     64 
     65   </script>
     66 
     67 </body>
     68 </html>
     69