wallet-core/thirdparty/systemjs/test/test-jsextensions.html

112 lines
2.6 KiB
HTML
Raw Normal View History

<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
<script src="../bower_components/qunit/qunit/qunit.js"></script>
</head>
<body>
<h1 id="qunit-header">SystemJS Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-test-area"></div>
<script>
// test polyfill loading
// window.URL = undefined;
</script>
<script src="../dist/system.src.js" type="text/javascript"></script>
<script>
System.traceurOptions = { asyncFunctions: true };
System.paths.traceur = '../node_modules/traceur/bin/traceur.js';
QUnit.config.testTimeout = 2000;
QUnit.module("SystemJS JS Extensions");
System.config({
defaultJSExtensions: true
});
asyncTest('Error handling', function() {
System['import']('tests/main').then(function(m) {
ok(m.dep == 'value');
start();
});
});
asyncTest('Pathing extension handling', function() {
System.config({
paths: {
'path': 'tests/main'
},
packages: {
'tests/testpkg': {
basePath: 'lib',
defaultExtension: 'ts',
map: {
'./asdf': './test.ts'
}
},
'tests/subcontextual-map': {
main: 'submodule',
map: {
dep: 'path'
}
}
}
});
Promise.all([
System['import']('path'),
System['import']('tests/testpkg/asdf'),
System['import']('tests/subcontextual-map'),
System['import']('tests/main-dep'),
System['import']('tests/main-dep.js')
])
.then(function(mods) {
ok(mods[0].dep == 'value');
ok(mods[1] == 'ts');
ok(mods[2].dep == 'value');
ok(mods[3] == mods[2]);
ok(mods[3] == mods[4]);
start();
})
});
System.config({
packages: {
'custom': {
defaultExtension: 'ext'
}
}
});
asyncTest('Register extensions', function(err) {
System['import']('tests/register-default-extension.js').then(function() {
System['import']('custom/file.ext').then(function(m) {
ok(m.custom == 'ext');
start();
}, err);
}, err);
});
System.config({
packages: {
'tests/no-default-ext': {
defaultExtension: false
}
}
});
asyncTest('No default extension', function(err) {
System['import']('tests/no-default-ext/file.ext').then(function(m) {
ok(m.ext == 'ext');
start();
}, err);
});
</script>
</body>
</html>