1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
<script src="../bower_components/qunit/qunit/qunit.js"></script>
</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>
// test polyfill loading
// window.URL = undefined;
</script>
<script src="../dist/system.src.js" type="text/javascript"></script>
<script>
System.traceurOptions = { asyncFunctions: true };
System.paths.traceur = '../node_modules/traceur/bin/traceur.js';
QUnit.config.testTimeout = 2000;
QUnit.module("SystemJS JS Extensions");
System.config({
defaultJSExtensions: true
});
asyncTest('Error handling', function() {
System['import']('tests/main').then(function(m) {
ok(m.dep == 'value');
start();
});
});
asyncTest('Pathing extension handling', function() {
System.config({
paths: {
'path': 'tests/main'
},
packages: {
'tests/testpkg': {
basePath: 'lib',
defaultExtension: 'ts',
map: {
'./asdf': './test.ts'
}
},
'tests/subcontextual-map': {
main: 'submodule',
map: {
dep: 'path'
}
}
}
});
Promise.all([
System['import']('path'),
System['import']('tests/testpkg/asdf'),
System['import']('tests/subcontextual-map'),
System['import']('tests/main-dep'),
System['import']('tests/main-dep.js')
])
.then(function(mods) {
ok(mods[0].dep == 'value');
ok(mods[1] == 'ts');
ok(mods[2].dep == 'value');
ok(mods[3] == mods[2]);
ok(mods[3] == mods[4]);
start();
})
});
System.config({
packages: {
'custom': {
defaultExtension: 'ext'
}
}
});
asyncTest('Register extensions', function(err) {
System['import']('tests/register-default-extension.js').then(function() {
System['import']('custom/file.ext').then(function(m) {
ok(m.custom == 'ext');
start();
}, err);
}, err);
});
System.config({
packages: {
'tests/no-default-ext': {
defaultExtension: false
}
}
});
asyncTest('No default extension', function(err) {
System['import']('tests/no-default-ext/file.ext').then(function(m) {
ok(m.ext == 'ext');
start();
}, err);
});
</script>
</body>
</html>
|