OLD | NEW |
| (Empty) |
1 <!doctype html> | |
2 <html> | |
3 <head> | |
4 <title>polymer-collapse</title> | |
5 <script src="../../../platform/platform.js"></script> | |
6 <script src="../../../tools/test/htmltest.js"></script> | |
7 <script src="../../../tools/test/chai/chai.js"></script> | |
8 <link rel="import" href="../../polymer-collapse.html"> | |
9 </head> | |
10 <body> | |
11 <button onclick="document.querySelector('#collapse').toggle()">toggle collapse
</button> | |
12 <div id="box"> | |
13 Forma temperiemque cornua sidera dissociata cornua recessit innabilis ligavi
t: solidumque coeptis nullus caelum sponte phoebe di regat mentisque tanta austr
o capacius amphitrite sui quin postquam semina fossae liquidum umor galeae coept
is caligine liberioris quin liquidum matutinis invasit posset: flexi glomeravit
radiis certis invasit oppida postquam onerosior inclusum dominari opifex terris
pace finxit quam aquae nunc sine altae auroram quam habentem homo totidemque scy
thiam in pondus ensis tegit caecoque poena lapidosos humanas coeperunt poena aet
as totidem nec natura aethera locavit caelumque distinxit animalibus phoebe cing
ebant moderantum porrexerat terrae possedit sua sole diu summaque obliquis melio
ris orbem | |
14 </div> | |
15 <polymer-collapse id="collapse" targetId="box" duration="0.1"></polymer-collap
se> | |
16 | |
17 <script> | |
18 var assert = chai.assert; | |
19 var delay = 200; | |
20 document.addEventListener('polymer-ready', function() { | |
21 var c = document.querySelector('#collapse'); | |
22 assert.equal(c.closed, false); | |
23 Platform.flush(); | |
24 setTimeout(function() { | |
25 var origH = getBoxComputedHeight(); | |
26 assert.notEqual(origH, 0); | |
27 c.closed = true; | |
28 Platform.flush(); | |
29 setTimeout(function() { | |
30 // after closed, height is 0 | |
31 assert.equal(getBoxComputedHeight(), 0); | |
32 // should be set to display: none | |
33 assert.equal(getBoxComputedStyle().display, 'none'); | |
34 c.closed = false; | |
35 Platform.flush(); | |
36 setTimeout(function() { | |
37 // verify computed height | |
38 assert.equal(getBoxComputedHeight(), origH); | |
39 // after opened, height is set to 'auto' | |
40 assert.equal(document.querySelector('#box').style.height, 'auto'); | |
41 done(); | |
42 }, delay); | |
43 }, delay); | |
44 }, delay); | |
45 }); | |
46 | |
47 function getBoxComputedStyle() { | |
48 var b = document.querySelector('#box'); | |
49 return getComputedStyle(b); | |
50 } | |
51 | |
52 function getBoxComputedHeight() { | |
53 return parseInt(getBoxComputedStyle().height); | |
54 } | |
55 </script> | |
56 </body> | |
57 </html> | |
OLD | NEW |