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 12<html> 13 <head> 14 <title>iron-collapse-nested</title> 15 <meta charset="utf-8"> 16 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 17 18 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> 19 <script src="../../web-component-tester/browser.js"></script> 20 <script src="../../test-fixture/test-fixture-mocha.js"></script> 21 22 <link rel="import" href="../../test-fixture/test-fixture.html"> 23 <link rel="import" href="../iron-collapse.html"> 24 </head> 25 <body> 26 27 <test-fixture id="test"> 28 <template> 29 <iron-collapse id="outer-collapse"> 30 <div style="height:100px;"> 31 Lorem ipsum 32 </div> 33 34 <iron-collapse id="inner-collapse-vertical"> 35 <div style="height:100px;"> 36 consectetur adipiscing elit 37 </div> 38 </iron-collapse> 39 40 <iron-collapse id="inner-collapse-horizontal" horizontal style="display: inline-block"> 41 <div style="width:100px;"> 42 consectetur adipiscing elit 43 </div> 44 </iron-collapse> 45 </iron-collapse> 46 </template> 47 </test-fixture> 48 49 <script> 50 51 suite('nested', function() { 52 53 var outerCollapse; 54 var innerCollapse; 55 56 setup(function () { 57 outerCollapse = fixture('test'); 58 }); 59 60 suite('vertical', function() { 61 62 setup(function () { 63 innerCollapse = outerCollapse.querySelector('#inner-collapse-vertical'); 64 }); 65 66 test('inner collapse default opened attribute', function() { 67 assert.equal(innerCollapse.opened, false); 68 }); 69 70 test('inner collapse default style height', function() { 71 assert.equal(innerCollapse.style.maxHeight, '0px'); 72 }); 73 74 test('open inner collapse updates size without animation', function() { 75 innerCollapse.opened = true; 76 77 // Animation disabled 78 assert.equal(innerCollapse.style.transitionDuration, '0s'); 79 }); 80 81 test('open inner collapse then open outer collapse reveals inner collapse with expanded height', function() { 82 innerCollapse.opened = true; 83 outerCollapse.opened = true; 84 85 assert.equal(innerCollapse.getBoundingClientRect().height, 100); 86 }); 87 88 test('notifyResize triggered only on element\'s animations', function(done) { 89 var spy = sinon.spy(outerCollapse, 'notifyResize'); 90 91 outerCollapse.opened = true; 92 innerCollapse.opened = true; 93 94 setTimeout(function() { 95 assert.equal(spy.callCount, 1, 'notifyResize called once'); 96 done(); 97 }, 400); 98 }); 99 100 }); 101 102 suite('horizontal', function() { 103 104 setup(function () { 105 innerCollapse = outerCollapse.querySelector('#inner-collapse-horizontal'); 106 }); 107 108 test('inner collapse default style width', function() { 109 assert.equal(innerCollapse.style.maxWidth, '0px'); 110 }); 111 112 test('open inner collapse updates size without animation', function() { 113 innerCollapse.opened = true; 114 115 // Animation disabled 116 assert.equal(innerCollapse.style.transitionDuration, '0s'); 117 }); 118 119 test('open inner collapse then open outer collapse reveals inner collapse with expanded width', function() { 120 innerCollapse.opened = true; 121 outerCollapse.opened = true; 122 123 assert.equal(innerCollapse.getBoundingClientRect().width, 100); 124 }); 125 126 }); 127 }); 128 </script> 129 130 </body> 131</html> 132