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

Commit

Permalink
migrate some tests from polymer-*, but not HOOKED UP or UPDATED
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott J. Miles committed Apr 14, 2014
1 parent 0011fcc commit cd00190
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/core-collapse.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!doctype html>
<html>
<head>
<title>polymer-collapse</title>
<script src="../../../platform/platform.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="../../polymer-collapse.html">
</head>
<body>
<button onclick="document.querySelector('#collapse').toggle()">toggle collapse</button>
<div id="box">
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
</div>
<polymer-collapse id="collapse" targetId="box" duration="0.1"></polymer-collapse>

<script>
var assert = chai.assert;
var delay = 200;
document.addEventListener('polymer-ready', function() {
var c = document.querySelector('#collapse');
assert.equal(c.closed, false);
Platform.flush();
setTimeout(function() {
var origH = getBoxComputedHeight();
assert.notEqual(origH, 0);
c.closed = true;
Platform.flush();
setTimeout(function() {
// after closed, height is 0
assert.equal(getBoxComputedHeight(), 0);
// should be set to display: none
assert.equal(getBoxComputedStyle().display, 'none');
c.closed = false;
Platform.flush();
setTimeout(function() {
// verify computed height
assert.equal(getBoxComputedHeight(), origH);
// after opened, height is set to 'auto'
assert.equal(document.querySelector('#box').style.height, 'auto');
done();
}, delay);
}, delay);
}, delay);
});

function getBoxComputedStyle() {
var b = document.querySelector('#box');
return getComputedStyle(b);
}

function getBoxComputedHeight() {
return parseInt(getBoxComputedStyle().height);
}
</script>
</body>
</html>
28 changes: 28 additions & 0 deletions tests/core-localstorage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<title>polymer-localstorage</title>
<script src="../../../platform/platform.js"></script>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="../../polymer-localstorage.html">
</head>
<body>

<polymer-localstorage id="localstorage" name="polymer-localstorage-test" useRaw></polymer-localstorage>

<script>
var assert = chai.assert;
document.addEventListener('polymer-ready', function() {
var s = document.querySelector('#localstorage');
var m = 'hello wold';
window.localStorage.setItem(s.name, m);
s.load();
assert.equal(s.value, m);
s.value = 'goodbye';
assert.equal(window.localStorage.getItem(s.name), m);
done();
});
</script>
</body>
</html>

0 comments on commit cd00190

Please sign in to comment.