OLD | NEW |
(Empty) | |
| 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.g
ithub.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/CONTRI
BUTORS.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/PATEN
TS.txt |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 |
| 14 <title>gold-cc-expiration-input 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 |
| 22 <script src="../../web-component-tester/browser.js"></script> |
| 23 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 24 |
| 25 <script src="../../iron-test-helpers/test-helpers.js"></script> |
| 26 |
| 27 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 28 <link rel="import" href="../gold-cc-expiration-input.html"> |
| 29 |
| 30 </head> |
| 31 <body> |
| 32 |
| 33 <test-fixture id="basic"> |
| 34 <template> |
| 35 <gold-cc-expiration-input auto-validate required error-message="error"></g
old-cc-expiration-input> |
| 36 </template> |
| 37 </test-fixture> |
| 38 |
| 39 <script> |
| 40 |
| 41 suite('basic', function() { |
| 42 test('invalid input is not ok', function() { |
| 43 var input = fixture('basic'); |
| 44 input.value='1234'; |
| 45 forceXIfStamp(input); |
| 46 |
| 47 var container = Polymer.dom(input.root).querySelector('paper-input-conta
iner'); |
| 48 assert.ok(container, 'paper-input-container exists'); |
| 49 assert.isTrue(container.invalid); |
| 50 }); |
| 51 |
| 52 test('misformed dates are not ok', function() { |
| 53 var input = fixture('basic'); |
| 54 input.value='33/33'; |
| 55 forceXIfStamp(input); |
| 56 |
| 57 var container = Polymer.dom(input.root).querySelector('paper-input-conta
iner'); |
| 58 assert.ok(container, 'paper-input-container exists'); |
| 59 assert.isTrue(container.invalid); |
| 60 }); |
| 61 |
| 62 test('past dates are not ok', function() { |
| 63 var input = fixture('basic'); |
| 64 input.value='11/00'; |
| 65 forceXIfStamp(input); |
| 66 |
| 67 var container = Polymer.dom(input.root).querySelector('paper-input-conta
iner'); |
| 68 assert.ok(container, 'paper-input-container exists'); |
| 69 assert.isTrue(container.invalid); |
| 70 }); |
| 71 |
| 72 test('future dates are ok', function() { |
| 73 var input = fixture('basic'); |
| 74 // Note: this test will start failing in 2099. Apologies, future maintai
ners. |
| 75 input.value='11/99'; |
| 76 forceXIfStamp(input); |
| 77 |
| 78 var container = Polymer.dom(input.root).querySelector('paper-input-conta
iner'); |
| 79 assert.ok(container, 'paper-input-container exists'); |
| 80 assert.isFalse(container.invalid); |
| 81 assert.equal(input.value, '11/99') |
| 82 }); |
| 83 |
| 84 test('value is updated correctly ', function() { |
| 85 var input = fixture('basic'); |
| 86 input.querySelector('.paper-input-input').month = 11; |
| 87 input.querySelector('.paper-input-input').year = 15; |
| 88 assert.equal(input.value, '11/15'); |
| 89 }); |
| 90 |
| 91 test('empty required input shows error', function() { |
| 92 var input = fixture('basic'); |
| 93 forceXIfStamp(input); |
| 94 |
| 95 var error = Polymer.dom(input.root).querySelector('paper-input-error'); |
| 96 assert.ok(error, 'paper-input-error exists'); |
| 97 assert.notEqual(getComputedStyle(error).display, 'none', 'error is not d
isplay:none'); |
| 98 }); |
| 99 |
| 100 }); |
| 101 |
| 102 suite('a11y', function() { |
| 103 |
| 104 test('has aria-labelledby', function() { |
| 105 var input = fixture('basic'); |
| 106 var month = input.querySelectorAll('input')[0]; |
| 107 var year = input.querySelectorAll('input')[1]; |
| 108 var label = Polymer.dom(input.root).querySelector('label').id; |
| 109 |
| 110 assert.ok(month); |
| 111 assert.ok(year); |
| 112 |
| 113 assert.isTrue(month.hasAttribute('aria-labelledby')); |
| 114 assert.isTrue(year.hasAttribute('aria-labelledby')); |
| 115 |
| 116 assert.equal(month.getAttribute('aria-labelledby'), label + ' monthLabel
'); |
| 117 assert.equal(year.getAttribute('aria-labelledby'), label + ' yearLabel')
; |
| 118 }); |
| 119 |
| 120 }); |
| 121 |
| 122 |
| 123 </script> |
| 124 |
| 125 </body> |
| 126 </html> |
OLD | NEW |