OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
9 --> | 9 --> |
10 | 10 |
11 <html> | 11 <html> |
12 <head> | 12 <head> |
13 <title>iron-collapse-horizontal</title> | 13 <title>iron-collapse-horizontal</title> |
14 <meta charset="utf-8"> | 14 <meta charset="utf-8"> |
15 <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 15 <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
16 | 16 |
17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> | 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
18 <script src="../../web-component-tester/browser.js"></script> | 18 <script src="../../web-component-tester/browser.js"></script> |
19 <script src="../../test-fixture/test-fixture-mocha.js"></script> | 19 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
20 | 20 |
21 <link rel="import" href="../../test-fixture/test-fixture.html"> | 21 <link rel="import" href="../../test-fixture/test-fixture.html"> |
22 <link rel="import" href="../iron-collapse.html"> | 22 <link rel="import" href="../iron-collapse.html"> |
23 </head> | 23 </head> |
24 <body> | 24 <body> |
25 | 25 |
26 <test-fixture id="test"> | 26 <test-fixture id="test"> |
27 <template> | 27 <template> |
28 <iron-collapse id="collapse" opened horizontal> | 28 <iron-collapse id="collapse" opened horizontal> |
29 <div> | 29 <div style="width:100px;"> |
30 Forma temperiemque cornua sidera dissociata cornua recessit innabili
s ligavit: solidumque coeptis nullus caelum sponte phoebe di regat mentisque tan
ta austro capacius amphitrite sui quin postquam semina fossae liquidum umor gale
ae coeptis caligine liberioris quin liquidum matutinis invasit posset: flexi glo
meravit radiis certis invasit oppida postquam onerosior inclusum dominari opifex
terris pace finxit quam aquae nunc sine altae auroram quam habentem homo totide
mque scythiam in pondus ensis tegit caecoque poena lapidosos humanas coeperunt p
oena aetas totidem nec natura aethera locavit caelumque distinxit animalibus pho
ebe cingebant moderantum porrexerat terrae possedit sua sole diu summaque obliqu
is melioris orbem | 30 Lorem ipsum |
31 </div> | 31 </div> |
32 </iron-collapse> | 32 </iron-collapse> |
33 </template> | 33 </template> |
34 </test-fixture> | 34 </test-fixture> |
35 | 35 |
36 <script> | 36 <script> |
37 | 37 |
38 suite('horizontal', function() { | 38 suite('horizontal', function() { |
39 | 39 |
40 var collapse; | 40 var collapse; |
41 var delay = 500; | 41 var collapseWidth; |
42 var collapseHeight; | |
43 | 42 |
44 setup(function () { | 43 setup(function () { |
45 collapse = fixture('test'); | 44 collapse = fixture('test'); |
| 45 collapseWidth = getComputedStyle(collapse).width; |
46 }); | 46 }); |
47 | 47 |
48 test('opened attribute', function() { | 48 test('opened attribute', function() { |
49 assert.equal(collapse.opened, true); | 49 assert.equal(collapse.opened, true); |
50 }); | 50 }); |
51 | 51 |
52 test('horizontal attribute', function() { | 52 test('horizontal attribute', function() { |
53 assert.equal(collapse.horizontal, true); | 53 assert.equal(collapse.horizontal, true); |
54 }); | 54 }); |
55 | 55 |
56 test('default opened width', function(done) { | 56 test('default opened width', function() { |
57 setTimeout(function() { | 57 assert.equal(collapse.style.width, 'auto'); |
58 // store actual width | |
59 width = getComputedStyle(collapse).width; | |
60 // verify width not 0px | |
61 assert.notEqual(width, '0px'); | |
62 done(); | |
63 }, delay); | |
64 }); | 58 }); |
65 | 59 |
66 test('set opened to false', function(done) { | 60 test('set opened to false, then to true', function(done) { |
| 61 // This listener will be triggered twice (every time `opened` changes)
. |
| 62 collapse.addEventListener('transitionend', function() { |
| 63 if (collapse.opened) { |
| 64 // Check finalSize after animation is done. |
| 65 assert.equal(collapse.style.width, 'auto'); |
| 66 done(); |
| 67 } else { |
| 68 // Check if size is still 0px. |
| 69 assert.equal(collapse.style.width, '0px'); |
| 70 // Trigger 2nd toggle. |
| 71 collapse.opened = true; |
| 72 // Size should be immediately set. |
| 73 assert.equal(collapse.style.width, collapseWidth); |
| 74 } |
| 75 }); |
| 76 // Trigger 1st toggle. |
67 collapse.opened = false; | 77 collapse.opened = false; |
68 setTimeout(function() { | 78 // Size should be immediately set. |
69 var h = getComputedStyle(collapse).width; | 79 assert.equal(collapse.style.width, '0px'); |
70 // verify width is 0px | |
71 assert.equal(h, '0px'); | |
72 done(); | |
73 }, delay); | |
74 }); | 80 }); |
75 | |
76 test('set opened to true', function(done) { | |
77 collapse.opened = true; | |
78 setTimeout(function() { | |
79 var h = getComputedStyle(collapse).width; | |
80 // verify width | |
81 assert.equal(h, width); | |
82 done(); | |
83 }, delay); | |
84 }); | |
85 | |
86 }); | 81 }); |
87 | 82 |
88 </script> | 83 </script> |
89 | 84 |
90 </body> | 85 </body> |
91 </html> | 86 </html> |
OLD | NEW |