OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 @license | 3 @license |
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 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 | 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 | 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 | 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 | 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 | 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
10 --> | 10 --> |
11 <html> | 11 <html> |
12 <head> | 12 <head> |
13 <meta charset="UTF-8"> | 13 <meta charset="UTF-8"> |
14 <title>paper-button basic tests</title> | 14 <title>paper-button basic tests</title> |
15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> | 15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> |
16 | 16 |
17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> | 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
18 <script src="../../web-component-tester/browser.js"></script> | 18 <script src="../../web-component-tester/browser.js"></script> |
19 <script src="../../test-fixture/test-fixture-mocha.js"></script> | |
20 <script src="../../iron-test-helpers/mock-interactions.js"></script> | 19 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
21 | 20 |
22 <link rel="import" href="../paper-button.html"> | 21 <link rel="import" href="../paper-button.html"> |
23 <link rel="import" href="../../test-fixture/test-fixture.html"> | |
24 | 22 |
25 </head> | 23 </head> |
26 <body> | 24 <body> |
27 | 25 |
28 <test-fixture id="TrivialButton"> | 26 <test-fixture id="TrivialButton"> |
29 <template> | 27 <template> |
30 <paper-button>Button</paper-button> | 28 <paper-button>Button</paper-button> |
31 </template> | 29 </template> |
32 </test-fixture> | 30 </test-fixture> |
33 | 31 |
34 <script> | 32 <script> |
35 suite('<paper-button>', function() { | 33 suite('<paper-button>', function() { |
36 var button; | 34 var button; |
37 | 35 |
38 setup(function() { | 36 setup(function() { |
39 button = fixture('TrivialButton'); | 37 button = fixture('TrivialButton'); |
40 }); | 38 }); |
41 | 39 |
42 test('can be raised imperatively', function(done) { | 40 test('can be raised imperatively', function(done) { |
43 button.raised = true; | 41 button.raised = true; |
44 | 42 |
45 expect(button.hasAttribute('raised')).to.be.eql(true); | 43 expect(button.hasAttribute('raised')).to.be.eql(true); |
46 | 44 |
47 Polymer.Base.async(function() { | 45 Polymer.Base.async(function() { |
48 try { | 46 try { |
49 expect(button._elevation).to.be.eql(1); | 47 expect(button.elevation).to.be.eql(1); |
50 done(); | 48 done(); |
51 } catch (e) { | 49 } catch (e) { |
52 done(e); | 50 done(e); |
53 } | 51 } |
54 }, 1); | 52 }, 1); |
55 }); | 53 }); |
56 | 54 |
57 test('has aria role "button"', function() { | 55 test('can be unraised after being raised imperatively', function(done) { |
58 expect(button.getAttribute('role')).to.be.eql('button'); | 56 button.raised = true; |
| 57 expect(button.hasAttribute('raised')).to.be.eql(true); |
| 58 |
| 59 Polymer.Base.async(function() { |
| 60 expect(button.elevation).to.be.eql(1); |
| 61 |
| 62 button.raised = false; |
| 63 expect(button.hasAttribute('raised')).to.be.eql(false); |
| 64 Polymer.Base.async(function() { |
| 65 expect(button.elevation).to.be.eql(0); |
| 66 done(); |
| 67 }, 1); |
| 68 }, 1); |
59 }); | 69 }); |
60 | 70 |
61 test('can be disabled imperatively', function() { | 71 test('can be disabled imperatively', function() { |
62 button.disabled = true; | 72 button.disabled = true; |
63 expect(button.getAttribute('aria-disabled')).to.be.eql('true'); | 73 expect(button.getAttribute('aria-disabled')).to.be.eql('true'); |
64 expect(button.hasAttribute('disabled')).to.be.eql(true); | 74 expect(button.hasAttribute('disabled')).to.be.eql(true); |
65 }); | 75 }); |
66 | 76 |
67 test('can be triggered with space', function(done) { | 77 test('can be triggered with space', function(done) { |
68 button.addEventListener('click', function() { | 78 button.addEventListener('click', function() { |
69 done(); | 79 done(); |
70 }); | 80 }); |
71 MockInteractions.pressSpace(button); | 81 MockInteractions.pressSpace(button); |
72 }); | 82 }); |
73 | 83 |
74 test('can be triggered with enter', function(done) { | 84 test('can be triggered with enter', function(done) { |
75 button.addEventListener('click', function() { | 85 button.addEventListener('click', function() { |
76 done(); | 86 done(); |
77 }); | 87 }); |
78 MockInteractions.pressEnter(button); | 88 MockInteractions.pressEnter(button); |
79 }); | 89 }); |
80 }); | 90 }); |
| 91 |
| 92 suite('<paper-button>', function() { |
| 93 var button; |
| 94 |
| 95 setup(function() { |
| 96 button = fixture('TrivialButton'); |
| 97 }); |
| 98 |
| 99 test('has aria role "button"', function() { |
| 100 expect(button.getAttribute('role')).to.be.eql('button'); |
| 101 }); |
| 102 |
| 103 a11ySuite('TrivialButton'); |
| 104 }); |
| 105 |
81 </script> | 106 </script> |
82 </body> | 107 </body> |
83 </html> | 108 </html> |
OLD | NEW |