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 <meta charset="UTF-8"> |
| 14 <title>paper-menu-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="../../test-fixture/test-fixture-mocha.js"></script> |
| 20 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
| 21 |
| 22 <link rel="import" href="../paper-menu-button.html"> |
| 23 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 24 |
| 25 </head> |
| 26 <body> |
| 27 |
| 28 <test-fixture id="TrivialMenuButton"> |
| 29 <template> |
| 30 <paper-menu-button no-animations> |
| 31 <span class="dropdown-trigger">trigger</span> |
| 32 <span class="dropdown-content">content</span> |
| 33 </paper-menu-button> |
| 34 </template> |
| 35 </test-fixture> |
| 36 |
| 37 <script> |
| 38 suite('<paper-menu-button>', function() { |
| 39 var menuButton; |
| 40 var trigger; |
| 41 var content; |
| 42 |
| 43 setup(function() { |
| 44 menuButton = fixture('TrivialMenuButton'); |
| 45 trigger = Polymer.dom(menuButton).querySelector('.dropdown-trigger'); |
| 46 content = Polymer.dom(menuButton).querySelector('.dropdown-content'); |
| 47 }); |
| 48 |
| 49 test('opens when trigger is clicked', function(done) { |
| 50 var contentRect; |
| 51 |
| 52 contentRect = content.getBoundingClientRect(); |
| 53 |
| 54 expect(contentRect.width).to.be.equal(0); |
| 55 expect(contentRect.height).to.be.equal(0); |
| 56 |
| 57 MockInteractions.tap(trigger); |
| 58 |
| 59 Polymer.Base.async(function() { |
| 60 contentRect = content.getBoundingClientRect(); |
| 61 |
| 62 expect(menuButton.opened).to.be.equal(true); |
| 63 |
| 64 expect(contentRect.width).to.be.greaterThan(0); |
| 65 expect(contentRect.height).to.be.greaterThan(0); |
| 66 done(); |
| 67 }); |
| 68 }); |
| 69 |
| 70 test('closes when trigger is clicked again', function(done) { |
| 71 MockInteractions.tap(trigger); |
| 72 |
| 73 Polymer.Base.async(function() { |
| 74 |
| 75 MockInteractions.tap(trigger); |
| 76 |
| 77 Polymer.Base.async(function() { |
| 78 var contentRect = content.getBoundingClientRect(); |
| 79 |
| 80 expect(menuButton.opened).to.be.equal(false); |
| 81 |
| 82 expect(contentRect.width).to.be.equal(0); |
| 83 expect(contentRect.height).to.be.equal(0); |
| 84 |
| 85 done(); |
| 86 }, Polymer.PaperMenuButton.MAX_ANIMATION_TIME_MS); |
| 87 }, 100); |
| 88 }); |
| 89 |
| 90 test('has aria-haspopup attribute', function() { |
| 91 expect(menuButton.hasAttribute('aria-haspopup')).to.be.equal(true); |
| 92 }); |
| 93 }); |
| 94 </script> |
| 95 </body> |
| 96 </html> |
OLD | NEW |