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

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Jan 21, 2014
1 parent 389e8b0 commit c39aa8c
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 125 deletions.
29 changes: 15 additions & 14 deletions test/html/HTMLImports.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@
}, 1000);
addEventListener('HTMLImportsLoaded', function() {
clearTimeout(timeout);
//console.dir(Object.keys(HTMLImports.cache));
chai.assert.equal(4, Object.keys(HTMLImports.importer.cache).length,
'must cache exactly four resources');
chai.assert.equal(4, Object.keys(HTMLImports.importer.documents).length,
'must cache exactly four documents');
if (!HTMLImports.useNative) {
chai.assert.equal(4, Object.keys(HTMLImports.importer.cache).length,
'must cache exactly four resources');
chai.assert.equal(4, Object.keys(HTMLImports.importer.documents).length,
'must cache exactly four documents');

Object.keys(HTMLImports.importer.documents).forEach(function(key) {
var doc = HTMLImports.importer.documents[key];
var links = doc.querySelectorAll('link[rel=import]');
Array.prototype.forEach.call(links, function(link) {
var href = link.getAttribute('href');
if (href.indexOf('404') <= 0) {
chai.assert.isDefined(link.import, 'import should have an import property');
}
Object.keys(HTMLImports.importer.documents).forEach(function(key) {
var doc = HTMLImports.importer.documents[key];
var links = doc.querySelectorAll('link[rel=import]');
Array.prototype.forEach.call(links, function(link) {
var href = link.getAttribute('href');
if (href.indexOf('404') <= 0) {
chai.assert.isDefined(link.import, 'import should have an import property');
}
});
});
})
}
done();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@
@import '../stuff/sheet.css';
@import 'sheet1.css';

.red {
background: red;
}

.foo {
background: url(../../foo.png);
}

.abs {
background: url(http://www.google.com);
.image {
background: url(google.png);
}
</style>
6 changes: 4 additions & 2 deletions test/html/load.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(function() {
function importLoaded(event) {
window.loadEvents++;
if (event.target.import) {
if (event.type === 'load' && event.target.import) {
var s = event.target.import.querySelector('script');
chai.assert.ok(s, 'load event target can be used to find element in import');
}
Expand All @@ -28,7 +28,9 @@
<div id="test3" class="image"></div>
<script>
document.addEventListener('HTMLImportsLoaded', function() {
chai.assert.equal(loadEvents, 3, 'expected # of load events');
// TODO(sorvell): onerror doesn't work in native, filing bug...
var num = HTMLImports.useNative ? 2 : 3;
chai.assert.equal(loadEvents, num, 'expected # of load events');
var test1 = getComputedStyle(document.querySelector('#test1')).backgroundColor;
chai.assert.equal(test1, 'rgb(255, 0, 0)');
var test2 = getComputedStyle(document.querySelector('#test2')).backgroundColor;
Expand Down
54 changes: 0 additions & 54 deletions test/html/path.html

This file was deleted.

2 changes: 1 addition & 1 deletion test/html/style-links.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<script src="../../html-imports.js"></script>
<link rel="import" href="imports/style-links.html">
<link rel="import" href="imports/style-links-import.html">
</head>
<body>
<script>
Expand Down
32 changes: 32 additions & 0 deletions test/html/style-paths.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTMLImports Path Tests</title>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<script src="../../html-imports.js"></script>
<link rel="import" href="imports/style-paths-import.html">
</head>
<body>
<div class="red">red</div>
<div class="image" style="height: 20px;"></div>
<script>

document.addEventListener('HTMLImportsLoaded', function() {
var i = document.querySelector('[rel=import]');
var doc = i.import;

var red = document.querySelector('.red');
chai.assert.equal(getComputedStyle(red).backgroundColor, 'rgb(255, 0, 0)', 'style in @import applied');
var image = document.querySelector('.image');

// document relative image url
var a = document.createElement('a');
a.href = 'imports/google.png';
chai.assert.match(getComputedStyle(image).backgroundImage, new RegExp(a.href), 'url in style applied');
done();
});
</script>
</body>
</html>
42 changes: 0 additions & 42 deletions test/html/urls.html

This file was deleted.

3 changes: 1 addition & 2 deletions test/js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ htmlSuite('HTMLImports', function() {
htmlTest('html/HTMLImports.html');
htmlTest('html/parser.html');
htmlTest('html/style-links.html');
htmlTest('html/path.html');
htmlTest('html/urls.html');
htmlTest('html/style-paths.html');
htmlTest('html/load.html');
htmlTest('html/currentScript.html');
htmlTest('html/dedupe.html');
Expand Down

0 comments on commit c39aa8c

Please sign in to comment.