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 <title>disabled-state</title> |
| 13 |
| 14 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 15 <script src="../../web-component-tester/browser.js"></script> |
| 16 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 17 |
| 18 <link rel="import" href="../../polymer/polymer.html"> |
| 19 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 20 <link rel="import" href="test-elements.html"> |
| 21 </head> |
| 22 <body> |
| 23 |
| 24 <test-fixture id="TrivialDisabledState"> |
| 25 <template> |
| 26 <test-control></test-control> |
| 27 </template> |
| 28 </test-fixture> |
| 29 |
| 30 <test-fixture id="InitiallyDisabledState"> |
| 31 <template> |
| 32 <test-control disabled></test-control> |
| 33 </template> |
| 34 </test-fixture> |
| 35 |
| 36 <script> |
| 37 suite('disabled-state', function() { |
| 38 var disableTarget; |
| 39 |
| 40 suite('a trivial disabled state', function() { |
| 41 setup(function() { |
| 42 disableTarget = fixture('TrivialDisabledState'); |
| 43 }); |
| 44 |
| 45 suite('when disabled is true', function() { |
| 46 test('receives a disabled attribute', function() { |
| 47 disableTarget.disabled = true; |
| 48 expect(disableTarget.hasAttribute('disabled')).to.be.eql(true); |
| 49 }); |
| 50 |
| 51 test('receives an appropriate aria attribute', function() { |
| 52 disableTarget.disabled = true; |
| 53 expect(disableTarget.getAttribute('aria-disabled')).to.be.eql('true'
); |
| 54 }); |
| 55 }); |
| 56 |
| 57 suite('when disabled is false', function() { |
| 58 test('loses the disabled attribute', function() { |
| 59 disableTarget.disabled = true; |
| 60 expect(disableTarget.hasAttribute('disabled')).to.be.eql(true); |
| 61 disableTarget.disabled = false; |
| 62 expect(disableTarget.hasAttribute('disabled')).to.be.eql(false); |
| 63 }); |
| 64 }); |
| 65 }); |
| 66 |
| 67 suite('a state with an initially disabled target', function() { |
| 68 setup(function() { |
| 69 disableTarget = fixture('InitiallyDisabledState'); |
| 70 }); |
| 71 |
| 72 test('preserves the disabled attribute on target', function() { |
| 73 expect(disableTarget.hasAttribute('disabled')).to.be.eql(true); |
| 74 expect(disableTarget.disabled).to.be.eql(true); |
| 75 }); |
| 76 |
| 77 test('adds `aria-disabled` to the target', function() { |
| 78 expect(disableTarget.getAttribute('aria-disabled')).to.be.eql('true'); |
| 79 }); |
| 80 }); |
| 81 }); |
| 82 </script> |
| 83 |
| 84 </body> |
| 85 </html> |
OLD | NEW |