Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 61514bc

Browse files
committed
add core-collapse and core-localstorage tests
1 parent cd00190 commit 61514bc

File tree

3 files changed

+65
-37
lines changed

3 files changed

+65
-37
lines changed

tests/core-collapse.html

+40-30
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,67 @@
11
<!doctype html>
2+
<!--
3+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.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/CONTRIBUTORS.txt
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/PATENTS.txt
9+
-->
210
<html>
311
<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">
12+
<title>core-collapse</title>
13+
14+
<script src="../../platform/platform.js"></script>
15+
<link rel="import" href="tools/tools.html">
16+
<script src="tools/htmltest.js"></script>
17+
18+
<link rel="import" href="../../core-collapse/core-collapse.html">
919
</head>
10-
<body>
20+
<body unresolved>
21+
1122
<button onclick="document.querySelector('#collapse').toggle()">toggle collapse</button>
12-
<div id="box">
23+
24+
<core-collapse id="collapse" duration="0.1" opened>
25+
<div>
1326
Forma temperiemque cornua sidera dissociata cornua recessit innabilis ligavit: solidumque coeptis nullus caelum sponte phoebe di regat mentisque tanta austro capacius amphitrite sui quin postquam semina fossae liquidum umor galeae coeptis 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 scythiam in pondus ensis tegit caecoque poena lapidosos humanas coeperunt poena aetas totidem nec natura aethera locavit caelumque distinxit animalibus phoebe cingebant moderantum porrexerat terrae possedit sua sole diu summaque obliquis melioris orbem
14-
</div>
15-
<polymer-collapse id="collapse" targetId="box" duration="0.1"></polymer-collapse>
27+
</div>
28+
</core-collapse>
1629

1730
<script>
18-
var assert = chai.assert;
19-
var delay = 200;
31+
var delay = 500;
2032
document.addEventListener('polymer-ready', function() {
2133
var c = document.querySelector('#collapse');
22-
assert.equal(c.closed, false);
23-
Platform.flush();
34+
// verify take attribute for opened is correct
35+
assert.equal(c.opened, true);
2436
setTimeout(function() {
25-
var origH = getBoxComputedHeight();
26-
assert.notEqual(origH, 0);
27-
c.closed = true;
37+
// get the height for the opened state
38+
var h = getCollapseComputedStyle().height;
39+
// verify the height is not 0px
40+
assert.notEqual(getCollapseComputedStyle().height, '0px');
41+
// close it
42+
c.opened = false;
2843
Platform.flush();
2944
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;
45+
// verify is closed
46+
assert.notEqual(getCollapseComputedStyle().height, h);
47+
// open it
48+
c.opened = true;
3549
Platform.flush();
3650
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');
51+
// verify is opened
52+
assert.equal(getCollapseComputedStyle().height, h);
4153
done();
4254
}, delay);
4355
}, delay);
4456
}, delay);
4557
});
4658

47-
function getBoxComputedStyle() {
48-
var b = document.querySelector('#box');
59+
function getCollapseComputedStyle() {
60+
var b = document.querySelector('#collapse');
4961
return getComputedStyle(b);
5062
}
5163

52-
function getBoxComputedHeight() {
53-
return parseInt(getBoxComputedStyle().height);
54-
}
5564
</script>
65+
5666
</body>
5767
</html>

tests/core-localstorage.html

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
<!doctype html>
2+
<!--
3+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.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/CONTRIBUTORS.txt
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/PATENTS.txt
9+
-->
210
<html>
311
<head>
4-
<title>polymer-localstorage</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-localstorage.html">
12+
<title>core-localstorage</title>
13+
14+
<script src="../../platform/platform.js"></script>
15+
<link rel="import" href="tools/tools.html">
16+
<script src="tools/htmltest.js"></script>
17+
18+
<link rel="import" href="../../core-localstorage/core-localstorage.html">
919
</head>
1020
<body>
1121

12-
<polymer-localstorage id="localstorage" name="polymer-localstorage-test" useRaw></polymer-localstorage>
22+
<core-localstorage id="localstorage" name="polymer-localstorage-test"></core-localstorage>
1323

1424
<script>
15-
var assert = chai.assert;
1625
document.addEventListener('polymer-ready', function() {
1726
var s = document.querySelector('#localstorage');
1827
var m = 'hello wold';
@@ -24,5 +33,6 @@
2433
done();
2534
});
2635
</script>
36+
2737
</body>
2838
</html>

tests/tests.html

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
htmlSuite('core-ajax', function() {
1818
htmlTest('tests/core-ajax.html');
1919
});
20+
21+
htmlSuite('core-collapse', function() {
22+
htmlTest('tests/core-collapse.html');
23+
});
24+
25+
htmlSuite('core-localstorage', function() {
26+
htmlTest('tests/core-localstorage.html');
27+
});
2028

2129
htmlSuite('core-selection', function() {
2230
htmlTest('tests/core-selection.html');

0 commit comments

Comments
 (0)