UNPKG

systemjs

Version:

System loader extension for flexible AMD & CommonJS support

184 lines (156 loc) 5.08 kB
<!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> </head> <body> <h1 id="qunit-header">SystemJS Test Suite</h1> <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests"></ol> <div id="qunit-test-area"></div> <script src="../dist/system-csp-production.src.js" type="text/javascript"></script> <script src="../bower_components/qunit/qunit/qunit.js"></script> <script> QUnit.config.testTimeout = 2000; QUnit.module("SystemJS CSP"); function err(e) { setTimeout(function() { throw e.stack || e; start(); }); } asyncTest('Loading an AMD module', function() { System['import']('tests/amd-module.js').then(function(m) { ok(m.amd == true); ok(m.dep.amd == 'dep'); start(); }, err); }); System.config({ bundles: { 'tests/amd-bundle.js': ['bundle-1', 'bundle-2'] } }); asyncTest('Loading an AMD bundle', function() { System['import']('bundle-1').then(function(m) { ok(m.defined == true); start(); }, err); stop(); System['import']('bundle-2').then(function(m) { ok(m.defined == true); start(); }, err); }); asyncTest('Loading an AMD named define', function() { System['import']('tests/nameddefine.js').then(function() { System['import']('another-define').then(function(m) { ok(m.named == 'define'); start(); }, err); }, err); }); asyncTest('Loading a badly named AMD define', function() { System['import']('tests/jquery-named.js').then(function(jquery) { ok(jquery.is == 'jquery'); start(); }, err); }); asyncTest('System.register Circular', function() { System['import']('tests/register-circular1.js').then(function(m) { ok(m.q == 3, 'Binding not allocated'); ok(m.r == 5, 'Binding not updated'); start(); }, err); }); asyncTest('Loading a UMD module', function() { System['import']('tests/umd.js').then(function(m) { ok(m.d == 'hi'); start(); }, err); }); asyncTest('Loading a bundle', function() { System['import']('tests/bundle.js').then(function(m) { return System['import']('bundle-define1'); }) .then(function(m) { ok(m.name == 'bundle1'); return System['import']('bundle-define2'); }) .then(function(m) { ok(m.name == 'bundle2'); start(); }) ['catch'](err); }); asyncTest('Loading a bundle on demand', function() { System.config({ bundles: { 'tests/main-bundle.js': ['jquery'] } }); System['import']('jquery').then(function(m) { ok(m.name == 'jquery-bundled'); start(); }, err); }); System.config({ bundles: { 'tests/mixed-bundle.js': ['tree/third', 'tree/cjs', 'tree/jquery', 'tree/second', 'tree/global', 'tree/amd', 'tree/first'] } }); asyncTest('Loading AMD from a bundle', function() { System['import']('tree/amd').then(function(m) { ok(m.is == 'amd'); start(); }, err); }); asyncTest('Loading CommonJS from a bundle', function() { System['import']('tree/cjs').then(function(m) { ok(m.cjs === true); start(); }, err); }); asyncTest('Loading a Global from a bundle', function() { System['import']('tree/global').then(function(m) { ok(m === 'output'); start(); }, err); }); asyncTest('Loading named System.register', function() { System['import']('tree/third').then(function(m) { ok(m.some == 'exports'); start(); }, err); }); asyncTest('Loading System.register from ES6', function() { System['import']('tree/first').then(function(m) { ok(m.p == 5); start(); }); }); asyncTest('Running a simple non-fetch plugin', function() { System.set('tests/es6-plugin', System.newModule({ fetch: function() { return ''; }, instantiate: function() { return "plugin"; } })); System['import']('test/file!tests/es6-plugin').then(function(m) { ok(m == 'plugin'); start(); }); }); asyncTest('Loading a non-registering module', function() { System['import']('tests/global-dep.js')['catch'](function(e) { ok(e.toString().indexOf('did not call System.register or AMD define') != -1); start(); }); }) </script> </body> </html>