mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
265 lines
7.8 KiB
HTML
265 lines
7.8 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<script src="../../es6-module-loader/lib/es6-module-loader.js" type="text/javascript"></script>
|
|
<script src="../system.js" type="text/javascript"></script>
|
|
|
|
<script>
|
|
System.import('test-runner').then(function(runner) {
|
|
runner.execute([
|
|
{
|
|
name: 'Wrapper module support',
|
|
run: function(complete, err) {
|
|
System.import('tests/wrapper').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.default != 'default1')
|
|
return 'Wrapper module not defined.';
|
|
}
|
|
},
|
|
{
|
|
name: 'Basic exporting & importing',
|
|
run: function(complete, err) {
|
|
var m1, m2, m3, m4, err;
|
|
var checkComplete = function() {
|
|
if (m1 && m2 && m3 && m4 && err)
|
|
complete(m1, m2, m3, m4);
|
|
}
|
|
System.import('tests/default1').then(function(_m1) {
|
|
if (m1 === undefined)
|
|
m1 = null;
|
|
else
|
|
m1 = _m1;
|
|
checkComplete();
|
|
});
|
|
System.import('tests/default1').then(function(_m1) {
|
|
if (m1 === undefined)
|
|
m1 = null;
|
|
else
|
|
m1 = _m1;
|
|
checkComplete();
|
|
});
|
|
System.import('tests/default2').then(function(_m2) {
|
|
m2 = _m2;
|
|
checkComplete();
|
|
});
|
|
System.import('tests/asdf').then(function() {
|
|
}, function(_err) {
|
|
err = _err;
|
|
checkComplete();
|
|
});
|
|
System.import('tests/default3').then(function(_m3) {
|
|
m3 = _m3;
|
|
checkComplete();
|
|
});
|
|
System.import('tests/module').then(function(_m4) {
|
|
m4 = _m4;
|
|
checkComplete();
|
|
});
|
|
},
|
|
confirm: function(m1, m2, m3, m4) {
|
|
if (m1.default != 'default1')
|
|
return 'Error defining default 1';
|
|
if (m2.default != 'default2')
|
|
return 'Error defining default 2';
|
|
if (m3.default != 'default3')
|
|
return 'Error defining default 3';
|
|
if (m4.test != 'default3')
|
|
return 'Error defining module';
|
|
}
|
|
},
|
|
{
|
|
name: 'Error handling',
|
|
run: function(complete, err) {
|
|
System.import('tests/error').then(complete, err);
|
|
},
|
|
confirm: function() {
|
|
return;
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script loading',
|
|
run: function(complete, err) {
|
|
System.import('tests/global').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (!m.jQuery || !m.another)
|
|
return 'Global objects not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script with multiple objects the same',
|
|
run: function(complete, err) {
|
|
System.import('tests/global-multi').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.jquery != 'here')
|
|
return 'Multi globals not detected';
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script loading with inline shim',
|
|
run: function(complete, err) {
|
|
System.import('tests/global-inline-dep').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != '1.8.3')
|
|
return 'Global dependency not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script with inline exports',
|
|
run: function(complete, err) {
|
|
System.import('tests/global-inline-export').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'r')
|
|
return 'Inline export not applied'
|
|
}
|
|
},
|
|
{
|
|
name: 'Map configuration',
|
|
run: function(complete, err) {
|
|
System.map['maptest'] = 'tests/map-test';
|
|
System.import('maptest').then(complete, err)
|
|
},
|
|
confirm: function(m) {
|
|
if (m.maptest != 'maptest')
|
|
return 'Mapped module not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Map configuration subpath',
|
|
run: function(complete, err) {
|
|
System.import('maptest/sub').then(complete, err)
|
|
},
|
|
confirm: function(m) {
|
|
if (m.maptest != 'maptestsub')
|
|
return 'Mapped folder not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading an AMD module',
|
|
run: function(complete, err) {
|
|
System.import('tests/amd-module').then(complete, err);
|
|
},
|
|
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, err) {
|
|
System.import('tests/nameddefine').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (!m.converter)
|
|
return 'Showdown not loaded!';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading AMD CommonJS form',
|
|
run: function(complete, err) {
|
|
System.import('tests/amd-cjs-module').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.test != 'hi')
|
|
return 'Not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading a CommonJS module',
|
|
run: function(complete, err) {
|
|
System.import('tests/common-js-module').then(complete, err);
|
|
},
|
|
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, err) {
|
|
System.import('tests/umd').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.d != 'hi')
|
|
return 'module value not defined';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading ES6 with format hint',
|
|
run: function(complete, err) {
|
|
System.import('tests/es6-format').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading AMD with format hint',
|
|
run: function(complete, err) {
|
|
System.import('tests/amd-format').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.amd != 'amd')
|
|
return 'AMD not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading CJS with format hint',
|
|
run: function(complete, err) {
|
|
System.import('tests/cjs-format').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.cjs != 'cjs')
|
|
return 'CJS not loaded';
|
|
}
|
|
},
|
|
{
|
|
name: 'Simple compiler Plugin',
|
|
run: function(complete, err) {
|
|
System.map['coffee'] = 'tests/compiler-plugin';
|
|
System.import('tests/compiler-test.coffee!').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.output != 'plugin output')
|
|
return 'Plugin not working.';
|
|
if (m.extra != 'yay!')
|
|
return 'Compiler not working.';
|
|
}
|
|
},
|
|
{
|
|
name: 'Advanced compiler plugin',
|
|
run: function(complete, err) {
|
|
System.import('tests/compiler-test!tests/advanced-plugin').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.q != 'custom fetch!')
|
|
return 'Custom fetch not working';
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading from jspm',
|
|
run: function(complete, err) {
|
|
System.paths['github:*'] = 'https://github.jspm.io/*.js';
|
|
System.paths['npm:*'] = 'https://npm.jspm.io/*.js';
|
|
|
|
System.import('npm:underscore').then(complete);
|
|
},
|
|
confirm: function(m) {
|
|
if (typeof m.chain != 'function')
|
|
return 'Not loaded';
|
|
}
|
|
}
|
|
]);
|
|
}, function(err) {
|
|
setTimeout(function() {
|
|
throw err;
|
|
}, 1);
|
|
});
|
|
</script>
|