mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-18 14:53:14 +00:00
380 lines
10 KiB
HTML
380 lines
10 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<script src="../../es6-module-loader/lib/es6-module-loader.js" type="text/javascript"></script>
|
|
<script src="../loader.js" type="text/javascript"></script>
|
|
|
|
<script>
|
|
jspm.config({
|
|
urlArgs: '?test'
|
|
});
|
|
|
|
jspm.import('./test-runner', function(runner) {
|
|
runner.execute([
|
|
{
|
|
name: 'Wrapper module support',
|
|
run: function(complete) {
|
|
jspm.import('./tests/wrapper', complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'default1')
|
|
return 'Wrapper module not defined.';
|
|
}
|
|
},
|
|
{
|
|
name: 'Basic exporting & importing',
|
|
run: function(complete) {
|
|
var m1, m2, m3, m4, err;
|
|
var checkComplete = function() {
|
|
if (m1 && m2 && m3 && m4 && err)
|
|
complete(m1, m2, m3, m4);
|
|
}
|
|
jspm.import(['./tests/default1'], function(_m1) {
|
|
if (m1 === undefined)
|
|
m1 = null;
|
|
else
|
|
m1 = _m1;
|
|
checkComplete();
|
|
});
|
|
jspm.import(['./tests/default1'], function(_m1) {
|
|
if (m1 === undefined)
|
|
m1 = null;
|
|
else
|
|
m1 = _m1;
|
|
checkComplete();
|
|
});
|
|
jspm.import(['./tests/default2'], function(_m2) {
|
|
m2 = _m2;
|
|
checkComplete();
|
|
});
|
|
jspm.import(['./tests/asdf'], function() {
|
|
}, function(_err) {
|
|
err = _err;
|
|
checkComplete();
|
|
});
|
|
jspm.import('./tests/default3', function(_m3) {
|
|
m3 = _m3;
|
|
checkComplete();
|
|
});
|
|
jspm.import('./tests/module', function(_m4) {
|
|
m4 = _m4;
|
|
checkComplete();
|
|
});
|
|
},
|
|
confirm: function(m1, m2, m3, m4) {
|
|
if (m1 != 'default1')
|
|
return 'Error defining default 1';
|
|
if (m2 != 'default2')
|
|
return 'Error defining default 2';
|
|
if (m3 != 'default3')
|
|
return 'Error defining default 3';
|
|
if (m4.test != 'default3')
|
|
return 'Error defining module';
|
|
}
|
|
},
|
|
{
|
|
name: 'Error handling',
|
|
run: function(complete) {
|
|
jspm.import('./tests/error', complete);
|
|
},
|
|
confirm: function() {
|
|
return;
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script loading',
|
|
run: function(complete) {
|
|
jspm.import(['./tests/global'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (!m.jQuery || !m.another)
|
|
return 'Global objects not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script with multiple objects the same',
|
|
run: function(complete) {
|
|
jspm.import(['./tests/global-multi'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.jquery != 'here')
|
|
return 'Multi globals not detected';
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script loading with imports',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
shim: {
|
|
'./tests/global-with-dep': ['./global-dep']
|
|
}
|
|
});
|
|
jspm.import(['./tests/global-with-dep'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != '1.8.3')
|
|
return 'Global dependency not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script loading with inline imports',
|
|
run: function(complete) {
|
|
jspm.import('./tests/global-inline-dep', complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != '1.8.3')
|
|
return 'Global dependency not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script with export specified',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
shim: {
|
|
'./tests/global-with-export': {
|
|
exports: 'window.q.r'
|
|
}
|
|
}
|
|
});
|
|
jspm.import(['./tests/global-with-export'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'r')
|
|
return 'Exports value not correct'
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script with inline exports',
|
|
run: function(complete) {
|
|
jspm.import('./tests/global-inline-export', complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'r')
|
|
return 'Inline export not applied'
|
|
}
|
|
},
|
|
{
|
|
name: 'Endpoint configuration',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
endpoints: {
|
|
'mypath': './tests'
|
|
}
|
|
});
|
|
jspm.import(['mypath:path', 'mypath:deep/deep'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'path')
|
|
return 'module not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Endpoint config with custom main normalize',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
endpoints: {
|
|
'ep': {
|
|
location: './tests/ep',
|
|
normalize: function(name) {
|
|
if (name.split('/').length == 1)
|
|
name = name + '/main'
|
|
return name;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
jspm.import(['ep:some-repo'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (!m.main)
|
|
return 'incorrect module';
|
|
}
|
|
},
|
|
{
|
|
name: 'Map configuration',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
map: {
|
|
'maptest': './tests/map-test'
|
|
}
|
|
});
|
|
jspm.import(['maptest'], complete)
|
|
},
|
|
confirm: function(m) {
|
|
if (m.maptest != 'maptest')
|
|
return 'Mapped module not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Map main configuration',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
map: {
|
|
mapmain: './tests/my-app'
|
|
},
|
|
main: {
|
|
'./tests/my-app': 'main'
|
|
}
|
|
});
|
|
jspm.import(['mapmain', 'mapmain/submodule'], complete)
|
|
},
|
|
confirm: function(m1, m2) {
|
|
if (!m1.isMain)
|
|
return 'Main module not loaded';
|
|
if (!m2.isSubmodule)
|
|
return 'Submodule not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Package map configuration',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
map: {
|
|
'./tests/my-app': {
|
|
'jquery': './tests/my-app/jquery-mapped'
|
|
}
|
|
}
|
|
});
|
|
jspm.import(['./tests/my-app/map-test'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (!m.mapDep)
|
|
return 'Mapped package dependency not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading an AMD module',
|
|
run: function(complete) {
|
|
jspm.import(['./tests/amd-module'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.amd != true)
|
|
return 'Incorrect module';
|
|
if (m.dep.amd != 'dep')
|
|
return 'Dependency not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading an AMD named define',
|
|
run: function(complete) {
|
|
jspm.import(['github:coreyti/showdown@0.3.1/src/showdown'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (!m.converter)
|
|
return 'Showdown not loaded!';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading AMD CommonJS form',
|
|
run: function(complete) {
|
|
jspm.import(['./tests/amd-cjs-module'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.test != 'hi')
|
|
return 'Not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading a CommonJS module',
|
|
run: function(complete) {
|
|
jspm.import(['./tests/common-js-module'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.hello != 'world')
|
|
return 'module value not defined';
|
|
if (m.first != 'this is a dep')
|
|
return 'dep value not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading a UMD module',
|
|
run: function(complete) {
|
|
jspm.import(['./tests/umd'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.d != 'hi')
|
|
return 'module value not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Simple compiler Plugin',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
map: {
|
|
'coffee': './tests/compiler-plugin'
|
|
}
|
|
});
|
|
jspm.import(['./tests/compiler-test.coffee!'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.output != 'plugin output')
|
|
return 'Plugin not working.';
|
|
if (m.extra != 'yay!')
|
|
return 'Compiler not working.';
|
|
}
|
|
},
|
|
{
|
|
name: 'Text plugin',
|
|
run: function(complete) {
|
|
jspm.import('./tests/some-text.txt!text', complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'this is some text\n')
|
|
return 'Text not defined.';
|
|
}
|
|
},
|
|
{
|
|
name: 'JSON plugin',
|
|
run: function(complete) {
|
|
jspm.import('./tests/some-json.json!', complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.some != 'json')
|
|
return 'JSON not defined.';
|
|
}
|
|
},
|
|
{
|
|
name: 'Image plugin',
|
|
run: function(complete) {
|
|
jspm.import('http://jspm.io/icons.png!image', complete);
|
|
},
|
|
confirm: function(m) {
|
|
}
|
|
},
|
|
{
|
|
name: 'CSS plugin',
|
|
run: function(complete) {
|
|
jspm.import('./tests/css.css!', complete);
|
|
},
|
|
confirm: function(m) {
|
|
}
|
|
},
|
|
{
|
|
name: 'Font plugin',
|
|
run: function(complete) {
|
|
jspm.import('#google Port Lligat Slab !font', complete);
|
|
},
|
|
confirm: function(m) {
|
|
}
|
|
},
|
|
{
|
|
name: 'onLoad hook',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
onLoad: complete
|
|
});
|
|
jspm.import(['./tests/normalize-hook-test']);
|
|
},
|
|
confirm: function(name, source, options) {
|
|
jspm.config({
|
|
onLoad: null
|
|
});
|
|
if (name != './tests/normalize-hook-test')
|
|
return 'normalize hook has incorrect name';
|
|
if (source != '"hello world";')
|
|
return 'invalid source';
|
|
}
|
|
}
|
|
]);
|
|
});
|
|
</script>
|