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 <meta charset="UTF-8"> |
| 13 <title>paper-radio-button basic tests</title> |
| 14 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> |
| 15 |
| 16 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 17 <script src="../../web-component-tester/browser.js"></script> |
| 18 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 19 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
| 20 |
| 21 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 22 <link rel="import" href="../paper-checkbox.html"> |
| 23 |
| 24 </head> |
| 25 <body> |
| 26 |
| 27 <test-fixture id="NoLabel"> |
| 28 <template> |
| 29 <paper-checkbox id="check1"></paper-checkbox> |
| 30 </template> |
| 31 </test-fixture> |
| 32 |
| 33 <test-fixture id="WithLabel"> |
| 34 <template> |
| 35 <paper-checkbox id="check2">Batman</paper-checkbox> |
| 36 </template> |
| 37 </test-fixture> |
| 38 |
| 39 <script> |
| 40 suite('defaults', function() { |
| 41 var c1; |
| 42 |
| 43 setup(function() { |
| 44 c1 = fixture('NoLabel'); |
| 45 }); |
| 46 |
| 47 test('check checkbox via click', function() { |
| 48 c1.addEventListener('click', function() { |
| 49 assert.isTrue(c1.getAttribute('aria-checked')); |
| 50 assert.isTrue(c1.checked); |
| 51 done(); |
| 52 }); |
| 53 MockInteractions.down(c1); |
| 54 }); |
| 55 |
| 56 test('toggle checkbox via click', function() { |
| 57 c1.checked = true; |
| 58 c1.addEventListener('click', function() { |
| 59 assert.isFalse(c1.getAttribute('aria-checked')); |
| 60 assert.isFalse(c1.checked); |
| 61 done(); |
| 62 }); |
| 63 MockInteractions.down(c1); |
| 64 }); |
| 65 |
| 66 test('disabled checkbox cannot be clicked', function() { |
| 67 c1.disabled = true; |
| 68 c1.addEventListener('click', function() { |
| 69 assert.isTrue(c1.getAttribute('aria-checked')); |
| 70 assert.isTrue(c1.checked); |
| 71 done(); |
| 72 }); |
| 73 MockInteractions.down(c1); |
| 74 }); |
| 75 }); |
| 76 |
| 77 suite('a11y', function() { |
| 78 var c1; |
| 79 var c2; |
| 80 |
| 81 setup(function() { |
| 82 c1 = fixture('NoLabel'); |
| 83 c2 = fixture('WithLabel'); |
| 84 }); |
| 85 |
| 86 test('has aria role "checkbox"', function() { |
| 87 assert.isTrue(c1.getAttribute('role') == 'checkbox'); |
| 88 assert.isTrue(c2.getAttribute('role') == 'checkbox'); |
| 89 }); |
| 90 |
| 91 test('checkbox with no label has no aria label', function() { |
| 92 assert.isTrue(!c1.getAttribute('aria-label')); |
| 93 }); |
| 94 |
| 95 test('checkbox with a label sets an aria label', function() { |
| 96 assert.isTrue(c2.getAttribute('aria-label') == "Batman"); |
| 97 }); |
| 98 }); |
| 99 </script> |
| 100 </body> |
| 101 </html> |
OLD | NEW |