mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-18 14:53:14 +00:00
294 lines
7.9 KiB
HTML
294 lines
7.9 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({
|
|
locations: {
|
|
plugin: '../../jspm-plugins'
|
|
}
|
|
});
|
|
|
|
jspm.import('test-runner', function(runner) {
|
|
runner.execute([
|
|
{
|
|
name: 'Basic exporting & importing',
|
|
run: function(complete) {
|
|
var m1, m2, m3, err;
|
|
var checkComplete = function() {
|
|
if (m1 && m2 && m3 && err)
|
|
complete(m1, m2, m3);
|
|
}
|
|
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();
|
|
});
|
|
},
|
|
confirm: function(m1, m2, m3) {
|
|
if (m1 != 'default1')
|
|
return 'Error defining default 1';
|
|
if (m2 != 'default2')
|
|
return 'Error defining default 2';
|
|
if (m3 != 'default3')
|
|
return 'Error defining default 3';
|
|
}
|
|
},
|
|
{
|
|
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 loading with depends',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
depends: {
|
|
'tests/global-with-dep': ['tests/global-dep']
|
|
}
|
|
});
|
|
jspm.import(['tests/global-with-dep'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.jQueryVersion != '1.8.3')
|
|
return 'Global dependency not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Inline depends configuration',
|
|
run: function(complete) {
|
|
jspm.import('tests/inline-depends | tests/inline-depends-dep', complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.dep != 'dep')
|
|
return 'Inline depends dependency not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Location configuration',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
locations: {
|
|
'mypath': 'tests'
|
|
}
|
|
});
|
|
jspm.import(['mypath:path'], complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.p != 'path')
|
|
return 'module not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Location relative resolution',
|
|
run: function(complete) {
|
|
jspm.config({
|
|
locations: {
|
|
'mylocation': 'tests/location'
|
|
}
|
|
});
|
|
jspm.import(['mylocation:main'], complete)
|
|
},
|
|
confirm: function(m) {
|
|
if (m.p != 'yay')
|
|
return 'relative location not loaded';
|
|
}
|
|
},
|
|
{
|
|
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: '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 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: {
|
|
'plugin: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: 'Handlebars plugin',
|
|
run: function(complete) {
|
|
jspm.import('tests/hbs.hbs!', complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (m({ title: 'hello' }) != '<h1>hello</h1>\n')
|
|
return 'Handlebars template not compiled';
|
|
}
|
|
},
|
|
{
|
|
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://octodex.github.com/images/codercat.jpg!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, Droid Sans !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>
|