OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 @license | 3 @license |
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 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 | 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 | 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 | 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 | 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 | 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
10 --> | 10 --> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 test('animated by default', function() { | 55 test('animated by default', function() { |
56 assert.isTrue(!collapse.noAnimation, '`noAnimation` is falsy'); | 56 assert.isTrue(!collapse.noAnimation, '`noAnimation` is falsy'); |
57 }); | 57 }); |
58 | 58 |
59 test('horizontal attribute', function() { | 59 test('horizontal attribute', function() { |
60 assert.equal(collapse.horizontal, false); | 60 assert.equal(collapse.horizontal, false); |
61 }); | 61 }); |
62 | 62 |
63 test('default opened height', function() { | 63 test('default opened height', function() { |
64 assert.equal(collapse.style.height, 'auto'); | 64 assert.equal(collapse.style.maxHeight, ''); |
65 }); | 65 }); |
66 | 66 |
67 test('set opened to false triggers animation', function(done) { | 67 test('set opened to false triggers animation', function(done) { |
68 collapse.opened = false; | 68 collapse.opened = false; |
69 // Animation got enabled. | 69 // Animation got enabled. |
70 assert.notEqual(collapse.style.transitionDuration, '0s'); | 70 assert.notEqual(collapse.style.transitionDuration, '0s'); |
71 collapse.addEventListener('transitionend', function() { | 71 collapse.addEventListener('transitionend', function() { |
72 // Animation disabled. | 72 // Animation disabled. |
73 assert.equal(collapse.style.transitionDuration, '0s'); | 73 assert.equal(collapse.style.transitionDuration, '0s'); |
74 done(); | 74 done(); |
75 }); | 75 }); |
76 }); | 76 }); |
77 | 77 |
78 test('enableTransition(false) disables animations', function() { | 78 test('enableTransition(false) disables animations', function() { |
79 collapse.enableTransition(false); | 79 collapse.enableTransition(false); |
80 assert.isTrue(collapse.noAnimation, '`noAnimation` is true'); | 80 assert.isTrue(collapse.noAnimation, '`noAnimation` is true'); |
81 // trying to animate the size update | 81 // trying to animate the size update |
82 collapse.updateSize('0px', true); | 82 collapse.updateSize('0px', true); |
83 // Animation immediately disabled. | 83 // Animation immediately disabled. |
84 assert.equal(collapse.style.height, '0px'); | 84 assert.equal(collapse.style.maxHeight, '0px'); |
85 }); | 85 }); |
86 | 86 |
87 test('set opened to false, then to true', function(done) { | 87 test('set opened to false, then to true', function(done) { |
88 // this listener will be triggered twice (every time `opened` changes) | 88 // this listener will be triggered twice (every time `opened` changes) |
89 collapse.addEventListener('transitionend', function() { | 89 collapse.addEventListener('transitionend', function() { |
90 if (collapse.opened) { | 90 if (collapse.opened) { |
91 // Check finalSize after animation is done. | 91 // Check finalSize after animation is done. |
92 assert.equal(collapse.style.height, 'auto'); | 92 assert.equal(collapse.style.height, ''); |
93 done(); | 93 done(); |
94 } else { | 94 } else { |
95 // Check if size is still 0px. | 95 // Check if size is still 0px. |
96 assert.equal(collapse.style.height, '0px'); | 96 assert.equal(collapse.style.maxHeight, '0px'); |
97 // Trigger 2nd toggle. | 97 // Trigger 2nd toggle. |
98 collapse.opened = true; | 98 collapse.opened = true; |
99 // Size should be immediately set. | 99 // Size should be immediately set. |
100 assert.equal(collapse.style.height, collapseHeight); | 100 assert.equal(collapse.style.maxHeight, collapseHeight); |
101 } | 101 } |
102 }); | 102 }); |
103 // Trigger 1st toggle. | 103 // Trigger 1st toggle. |
104 collapse.opened = false; | 104 collapse.opened = false; |
105 // Size should be immediately set. | 105 // Size should be immediately set. |
106 assert.equal(collapse.style.height, '0px'); | 106 assert.equal(collapse.style.maxHeight, '0px'); |
107 }); | 107 }); |
108 | 108 |
109 test('opened changes trigger iron-resize', function() { | 109 test('opened changes trigger iron-resize', function() { |
110 var spy = sinon.stub(); | 110 var spy = sinon.stub(); |
111 collapse.addEventListener('iron-resize', spy); | 111 collapse.addEventListener('iron-resize', spy); |
112 // No animations for faster test. | 112 // No animations for faster test. |
113 collapse.noAnimation = true; | 113 collapse.noAnimation = true; |
114 collapse.opened = false; | 114 collapse.opened = false; |
115 assert.isTrue(spy.calledOnce, 'iron-resize was fired'); | 115 assert.isTrue(spy.calledOnce, 'iron-resize was fired'); |
116 }); | 116 }); |
117 | 117 |
118 test('overflow is hidden while animating', function(done) { | 118 test('overflow is hidden while animating', function(done) { |
119 collapse.addEventListener('transitionend', function() { | 119 collapse.addEventListener('transitionend', function() { |
120 // Should still be hidden. | 120 // Should still be hidden. |
121 assert.equal(getComputedStyle(collapse).overflow, 'hidden'); | 121 assert.equal(getComputedStyle(collapse).overflow, 'hidden'); |
122 done(); | 122 done(); |
123 }); | 123 }); |
124 assert.equal(getComputedStyle(collapse).overflow, 'visible'); | 124 assert.equal(getComputedStyle(collapse).overflow, 'visible'); |
125 collapse.opened = false; | 125 collapse.opened = false; |
126 // Immediately updated style. | 126 // Immediately updated style. |
127 assert.equal(getComputedStyle(collapse).overflow, 'hidden'); | 127 assert.equal(getComputedStyle(collapse).overflow, 'hidden'); |
128 }); | 128 }); |
129 | 129 |
130 test('toggle horizontal updates size', function() { | 130 test('toggle horizontal updates size', function() { |
131 collapse.horizontal = false; | 131 collapse.horizontal = false; |
132 assert.equal(collapse.style.width, ''); | 132 assert.equal(collapse.style.width, ''); |
133 assert.equal(collapse.style.height, 'auto'); | 133 assert.equal(collapse.style.maxHeight, ''); |
134 assert.equal(collapse.style.transitionProperty, 'height'); | 134 assert.equal(collapse.style.transitionProperty, 'max-height'); |
135 | 135 |
136 collapse.horizontal = true; | 136 collapse.horizontal = true; |
137 assert.equal(collapse.style.width, 'auto'); | 137 assert.equal(collapse.style.maxWidth, ''); |
138 assert.equal(collapse.style.height, ''); | 138 assert.equal(collapse.style.height, ''); |
139 assert.equal(collapse.style.transitionProperty, 'width'); | 139 assert.equal(collapse.style.transitionProperty, 'max-width'); |
140 }); | 140 }); |
141 | 141 |
142 }); | 142 }); |
143 | 143 |
144 </script> | 144 </script> |
145 | 145 |
146 </body> | 146 </body> |
147 </html> | 147 </html> |
OLD | NEW |