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

Commit

Permalink
add imports to resolvePath testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jan 16, 2014
1 parent 527311f commit fbb29e1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/html/resolve/x-resolve-import.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<link rel="import" href="../../../polymer.html">

<polymer-element name="x-resolve-import" noscript>
</polymer-element>
<polymer-element name="x-resolve-import-ap" assetpath="foo/bar/baz/" noscript>
</polymer-element>
49 changes: 49 additions & 0 deletions test/html/resolvePath.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>resolvePath Imports</title>
<script src="../../../platform/platform.js"></script>
<link rel="import" href="../../polymer.html">
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<link rel="import" href="resolve/x-resolve-import.html">
<script>
var a = document.createElement('a');

function dirname() {
var pp = location.href.split('/');
pp.pop();
return pp.join('/');
}

// resolvePath may not remove '../', pass through an anchor to clean
function urlResolve(resolver, path) {
var junkyPath = resolver.resolvePath(path);
a.href = junkyPath;
// magical url voodoo
return a.href;
}

var assert = chai.assert;
</script>
</head>
<body>
<x-resolve-import id="xri"></x-resolve-import>
<x-resolve-import-ap id="xri-ap"></x-resolve-import-ap>

<script>
addEventListener('WebComponentsReady', function() {
var xri = document.querySelector('#xri');
assert.equal(urlResolve(xri, 'foo.js'), dirname() + '/resolve/foo.js');
assert.equal(urlResolve(xri, 'foo/bar'), dirname() + '/resolve/foo/bar');
// assert.equal(urlResolve(xri, 'http://example.com/foo'), 'http://example.com/foo');
var xriap = document.querySelector('#xri-ap');
assert.equal(urlResolve(xriap, 'foo.js'), dirname() + '/resolve/foo/bar/baz/foo.js');
assert.equal(urlResolve(xriap, 'foo/bar/foo.js'), dirname() + '/resolve/foo/bar/foo.js');
// assert.equal(urlResolve(xriap, 'http://example.com/foo'), 'http://example.com/foo');
done();
});
</script>
</body>
</html>
5 changes: 4 additions & 1 deletion test/js/resolvePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ suite('resolvePath', function() {
test('relative path', function() {
assert.equal(urlResolve(resolver, 'foo.js'), dirname() + '/foo.js');
assert.equal(urlResolve(resolver, 'bar/baz'), dirname() + '/bar/baz');
assert.equal(urlResolve(resolver, '../test/foo'), dirname() + '/foo');
});

test.skip('absolute path', function() {
Expand All @@ -63,3 +62,7 @@ suite('resolvePath', function() {
});

});

htmlSuite('resolvePath - imports', function() {
htmlTest('html/resolvePath.html');
});

0 comments on commit fbb29e1

Please sign in to comment.