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>iron-dropdown-scroll-manager 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="../iron-dropdown-scroll-manager.html"> |
| 23 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 24 </head> |
| 25 <body> |
| 26 |
| 27 <test-fixture id="DOMSubtree"> |
| 28 <template> |
| 29 <div id="Parent"> |
| 30 <div id="ChildOne"> |
| 31 <div id="GrandchildOne"></div> |
| 32 </div> |
| 33 <div id="ChildTwo"> |
| 34 <div id="GrandchildTwo"></div> |
| 35 </div> |
| 36 </div> |
| 37 </template> |
| 38 </test-fixture> |
| 39 <script> |
| 40 suite('IronDropdownScrollManager', function() { |
| 41 var parent; |
| 42 var childOne; |
| 43 var childTwo; |
| 44 var grandchildOne; |
| 45 var grandchildTwo; |
| 46 var ancestor; |
| 47 |
| 48 setup(function() { |
| 49 parent = fixture('DOMSubtree'); |
| 50 childOne = parent.querySelector('#ChildOne'); |
| 51 childTwo = parent.querySelector('#ChildTwo'); |
| 52 grandChildOne = parent.querySelector('#GrandchildOne'); |
| 53 grandChildTwo = parent.querySelector('#GrandchildTwo'); |
| 54 ancestor = document.body; |
| 55 }); |
| 56 |
| 57 suite('contraining scroll in the DOM', function() { |
| 58 setup(function() { |
| 59 Polymer.IronDropdownScrollManager.pushScrollLock(childOne); |
| 60 }); |
| 61 |
| 62 teardown(function() { |
| 63 Polymer.IronDropdownScrollManager.removeScrollLock(childOne); |
| 64 }); |
| 65 |
| 66 test('recognizes sibling as locked', function() { |
| 67 expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(childTw
o)) |
| 68 .to.be.equal(true); |
| 69 }); |
| 70 |
| 71 test('recognizes neice as locked', function() { |
| 72 expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(grandCh
ildTwo)) |
| 73 .to.be.equal(true); |
| 74 }); |
| 75 |
| 76 test('recognizes parent as locked', function() { |
| 77 expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(parent)
) |
| 78 .to.be.equal(true); |
| 79 }); |
| 80 |
| 81 test('recognizes ancestor as locked', function() { |
| 82 expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(ancesto
r)) |
| 83 .to.be.equal(true); |
| 84 }); |
| 85 |
| 86 test('recognizes locking child as unlocked', function() { |
| 87 expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(childOn
e)) |
| 88 .to.be.equal(false); |
| 89 }); |
| 90 |
| 91 test('recognizes descendant of locking child as unlocked', function() { |
| 92 expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(grandCh
ildOne)) |
| 93 .to.be.equal(false); |
| 94 }); |
| 95 |
| 96 test('unlocks locked elements when there are no locking elements', funct
ion() { |
| 97 Polymer.IronDropdownScrollManager.removeScrollLock(childOne); |
| 98 |
| 99 expect(Polymer.IronDropdownScrollManager.elementIsScrollLocked(parent)
) |
| 100 .to.be.equal(false); |
| 101 }); |
| 102 }); |
| 103 }); |
| 104 </script> |
| 105 </body> |
| 106 </html> |
OLD | NEW |