Skip to content

Commit

Permalink
[amd] refs brython-dev#188 - Intern configuration file. No test suite…
Browse files Browse the repository at this point in the history
…s defined
  • Loading branch information
olemis committed Feb 10, 2016
1 parent 6d8867b commit 4091255
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions www/tests/intern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

/* Intern configuration
In order to override dojo loader with require.js there should be
a global `amd` variable bound to an object containing, at least,
the following attributes.
- loader_path: Path/URL pointing at AMD loader file (e.g. require.js)
Alternatively, if using Intern browser client, it is possible to supply
the AMD loader script path/URL via `amdLoader=<URL>` argument when invoking
client.html e.g. http://localhost/intern/client.html?amdLoader=http://localhost/requirejs/require.js
*/

;(function() {
// See stackoverflow:2976651
var stk = new Error().stack.split('\n');
idx = 0;
for (var i in stk) {
if (!stk[i].match(/http[s]:\/\//)) continue;
idx = Number(i) + 2;
break;
}
var path_parts = stk[idx].match(/((http[s]?:\/\/.+\/)([^\/]+\.js)):/),
path_base = (path_parts? path_parts[2]: '') + '../',
path_requirejs_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.22/require.min.js',
amd_loader_arg = location.search.match(/[?&]amdLoader=([^&]+)/),
cfg_loader = {'host-node' : 'requirejs',
'host-browser' : this['amd']? amd.loader_path :
(amd_loader_arg? amd_loader_arg[1] :
path_requirejs_cdn)};
cfg_loader_options = {baseUrl: 'src/amd',
paths: {'brython_tests' : 'tests/amd/brython_tests'}}

define({
basePath: path_base,
// Intern 2.0
useLoader: cfg_loader,
loader: cfg_loader_options,
// Intern 3.0
loaders: cfg_loader,
loaderOptions: cfg_loader_options
})
})()

0 comments on commit 4091255

Please sign in to comment.