1<!doctype html> 2<!-- 3@license 4Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 5This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 6The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 7The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 8Code distributed by Google as part of the polymer project is also 9subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 10--> 11<html> 12<head> 13 <meta charset="UTF-8"> 14 <title>paper-button basic tests</title> 15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> 16 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> 18 <script src="../../web-component-tester/browser.js"></script> 19 <script src="../../iron-test-helpers/mock-interactions.js"></script> 20 21 <link rel="import" href="../paper-button.html"> 22 23</head> 24<body> 25 26 <test-fixture id="TrivialButton"> 27 <template> 28 <paper-button>Button</paper-button> 29 </template> 30 </test-fixture> 31 32 <script> 33 suite('<paper-button>', function() { 34 var button; 35 36 setup(function() { 37 button = fixture('TrivialButton'); 38 }); 39 40 test('can be raised imperatively', function(done) { 41 button.raised = true; 42 43 expect(button.hasAttribute('raised')).to.be.eql(true); 44 45 Polymer.Base.async(function() { 46 try { 47 expect(button.elevation).to.be.eql(1); 48 done(); 49 } catch (e) { 50 done(e); 51 } 52 }, 1); 53 }); 54 55 test('can be unraised after being raised imperatively', function(done) { 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); 69 }); 70 71 test('can be disabled imperatively', function() { 72 button.disabled = true; 73 expect(button.getAttribute('aria-disabled')).to.be.eql('true'); 74 expect(button.hasAttribute('disabled')).to.be.eql(true); 75 }); 76 77 test('can be triggered with space', function(done) { 78 button.addEventListener('click', function() { 79 done(); 80 }); 81 MockInteractions.pressSpace(button); 82 }); 83 84 test('can be triggered with enter', function(done) { 85 button.addEventListener('click', function() { 86 done(); 87 }); 88 MockInteractions.pressEnter(button); 89 }); 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 106 </script> 107</body> 108</html> 109