systemjs/test/test.html
2013-06-26 18:23:03 -07:00

224 lines
6.1 KiB
HTML

<!doctype html>
<html>
<script src="../../es6-loader/es6-loader.js" type="text/javascript"></script>
<script src="../jspm-loader.js" type="text/javascript"></script>
<script>
jspm.import(['test-runner'], function(runner) {
runner.execute([
{
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';
if (window.jQuery || window.another)
return 'Global object has leaked';
}
},
{
name: 'Global script loading with shimDeps',
run: function(complete) {
jspm.config({
shimDeps: {
'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: 'Global paths configuration',
run: function(complete) {
jspm.config({
paths: {
'mypath': 'tests/path'
}
});
jspm.import(['mypath'], complete);
},
confirm: function(m) {
if (m.p != 'path')
return 'module not loaded';
}
},
{
name: 'External URL loading',
run: function(complete) {
jspm.import(['http://code.jquery.com/jquery-1.10.1.min.js'], complete);
},
confirm: function(m) {
if (m.jQuery.fn.jquery != '1.10.1')
return 'jQuery not loaded';
}
},
{
name: 'Global 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: 'Basic package configuration',
run: function(complete) {
jspm.config({
packages: {
myapp: {
path: 'tests/package-test',
main: 'themain'
}
}
});
jspm.import(['myapp', 'myapp/sub'], complete)
},
confirm: function(m1, m2) {
if (!m1.package)
return 'Package not loaded';
if (!m2.package)
return 'Package subpath not loaded';
}
},
{
name: 'Package map configuration',
run: function(complete) {
jspm.config({
packages: {
myapp: {
map: {
'jquery': 'myapp/jquery-mapped'
}
}
}
});
jspm.import(['myapp/map-test'], complete);
},
confirm: function(m) {
if (!m.mapDep)
return 'Mapped package dependency not loaded';
}
},
{
name: 'Package paths configuration',
run: function(complete) {
jspm.config({
packages: {
myapp: {
paths: {
'jquery-cdn': "http://code.jquery.com/jquery-1.8.1.js"
}
}
}
});
jspm.import(['myapp/path-test'], complete);
},
confirm: function(m) {
if (m.jQuery.fn.jquery != '1.8.1')
return 'jQuery not defined';
}
},
{
name: 'Package shimDep configuration',
run: function(complete) {
jspm.config({
packages: {
myapp: {
paths: {
'jquery-1.8.2': "http://code.jquery.com/jquery-1.8.2.js"
},
shimDeps: {
'shim-test': ['jquery-1.8.2']
}
}
}
});
jspm.import(['myapp/shim-test'], complete);
},
confirm: function(m) {
if (m.myPlugin.jQuery.fn.jquery != '1.8.2')
return 'Wrong jQuery version';
}
},
{
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: '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: 'onLoad hook',
run: function(complete) {
jspm.config({
onLoad: complete
});
jspm.import(['tests/normalize-hook-test']);
},
confirm: function(name, source, options) {
if (name != 'tests/normalize-hook-test')
return 'normalize hook has incorrect name';
if (source != '"hello world";')
return 'invalid source';
}
}
]);
});
</script>