mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
346 lines
10 KiB
HTML
346 lines
10 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<script>
|
|
// window.Promise = null
|
|
</script>
|
|
<script src="../../es6-module-loader/lib/es6-module-loader.js" type="text/javascript"></script>
|
|
<!-- <script src="../dist/system-jspm.js" type="text/javascript"></script> -->
|
|
<script src="../dist/system-jspm.min.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: 'Global script with shim config',
|
|
run: function(complete, err) {
|
|
System.shim['~/tests/global-shim-config'] = ['./global-shim-config-dep'];
|
|
System.import('~/tests/global-shim-config').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'shimmed')
|
|
return 'Not shimmed';
|
|
}
|
|
},
|
|
{
|
|
name: 'Global script with shim config exports',
|
|
run: function(complete, err) {
|
|
System.shim['~/tests/global-shim-config-exports'] = { exports: 'p' };
|
|
System.import('~/tests/global-shim-config-exports').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'export')
|
|
return 'Exports not shimmed';
|
|
}
|
|
},
|
|
{
|
|
name: 'Map configuration',
|
|
run: function(complete, err) {
|
|
System.map['maptest'] = '~/tests/map-test';
|
|
System.map['~/tests/contextual-map'] = {
|
|
maptest: '~/tests/contextual-map-dep'
|
|
};
|
|
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: 'Contextual map configuration',
|
|
run: function(complete, err) {
|
|
System.import('~/tests/contextual-map').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.mapdep != 'mapdep')
|
|
return 'Contextual map dep 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: 'Module Name meta',
|
|
run: function(complete, err) {
|
|
System.import('~/tests/reflection').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.myname != '~/tests/reflection')
|
|
return 'Module name not returned';
|
|
}
|
|
},
|
|
{
|
|
name: 'Relative dyanamic loading',
|
|
run: function(complete, err) {
|
|
System.import('~/tests/reldynamic').then(function(m) {
|
|
m.dynamicLoad().then(complete, err);
|
|
}, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.dynamic != 'module')
|
|
return 'Dynamic load failed';
|
|
}
|
|
},
|
|
{
|
|
name: 'Versions support',
|
|
run: function(complete, err) {
|
|
System.versions['~/tests/versioned'] = '2.0.3';
|
|
System.import('~/tests/versioned@^2.0.3').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m.version != '2.3.4')
|
|
return 'Version 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: 'Legacy plugin',
|
|
run: function(complete, err) {
|
|
System.import('~/tests/default1.js!~/tests/legacy-plugin').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (!m.default)
|
|
return 'No Default';
|
|
if (!m.plugin)
|
|
return 'Not transpiled';
|
|
}
|
|
},
|
|
{
|
|
name: 'Advanced compiler plugin',
|
|
run: function(complete, err) {
|
|
System.import('~/tests/compiler-test!~/tests/advanced-plugin').then(complete, err);
|
|
},
|
|
confirm: function(m) {
|
|
if (m != 'custom fetch:~/tests/compiler-test!~/tests/advanced-plugin')
|
|
return m;
|
|
}
|
|
},
|
|
{
|
|
name: 'Loading from jspm',
|
|
run: function(complete, err) {
|
|
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>
|