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-tooltip 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="../../test-fixture/test-fixture.html"> |
| 23 <link rel="import" href="../paper-tooltip.html"> |
| 24 |
| 25 </head> |
| 26 <body> |
| 27 |
| 28 <test-fixture id="basic"> |
| 29 <template> |
| 30 <div> |
| 31 <div id="target"></div> |
| 32 <paper-tooltip for="target">Tooltip text</paper-tooltip> |
| 33 </div> |
| 34 </template> |
| 35 </test-fixture> |
| 36 |
| 37 <script> |
| 38 suite('basic', function() { |
| 39 var f, tooltip, target; |
| 40 |
| 41 setup(function() { |
| 42 f = fixture('basic'); |
| 43 target = f.querySelector('#target'); |
| 44 tooltip = f.querySelector('paper-tooltip'); |
| 45 }); |
| 46 |
| 47 test('tooltip is shown when target is focused', function() { |
| 48 var actualTooltip = Polymer.dom(tooltip.root).querySelector('#tooltip'); |
| 49 assert.isTrue(actualTooltip.hidden); |
| 50 |
| 51 MockInteractions.focus(target); |
| 52 assert.isFalse(actualTooltip.hidden); |
| 53 }); |
| 54 |
| 55 test('tooltip is hidden after target is blurred', function(done) { |
| 56 var actualTooltip = Polymer.dom(tooltip.root).querySelector('#tooltip'); |
| 57 assert.isTrue(actualTooltip.hidden); |
| 58 MockInteractions.focus(target); |
| 59 assert.isFalse(actualTooltip.hidden); |
| 60 |
| 61 tooltip.addEventListener('neon-animation-finish', function() { |
| 62 assert.isTrue(actualTooltip.hidden); |
| 63 done(); |
| 64 }); |
| 65 MockInteractions.blur(target); |
| 66 }); |
| 67 |
| 68 test('tooltip unlistens to target on detach', function(done) { |
| 69 sinon.spy(tooltip, 'show'); |
| 70 |
| 71 MockInteractions.focus(target); |
| 72 expect(tooltip.show.callCount).to.be.equal(1); |
| 73 |
| 74 MockInteractions.focus(target); |
| 75 expect(tooltip.show.callCount).to.be.equal(2); |
| 76 |
| 77 f.removeChild(tooltip); |
| 78 |
| 79 setTimeout(function() { |
| 80 // No more listener means no more calling show. |
| 81 MockInteractions.focus(target); |
| 82 expect(tooltip.show.callCount).to.be.equal(2); |
| 83 done(); |
| 84 }, 200); |
| 85 }); |
| 86 }); |
| 87 |
| 88 suite('a11y', function() { |
| 89 test('has aria role "tooltip"', function() { |
| 90 var f = fixture('basic'); |
| 91 var tooltip = f.querySelector('paper-tooltip'); |
| 92 |
| 93 assert.isTrue(tooltip.getAttribute('role') == 'tooltip'); |
| 94 }); |
| 95 }); |
| 96 </script> |
| 97 </body> |
| 98 </html> |
OLD | NEW |