Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
123 lines (105 sloc) 2.53 KB
<!DOCTYPE HTML>
<html>
<head>
<title>Paths test</title>
<script>
curl = curl_base = {
paths: {
curl: '../src/curl'
}
};
</script>
<script src="../src/curl.js" type="text/javascript"></script>
<script type="text/javascript">
(function () {
"use strict";
var tests, privateCfg, testRunner, domReady, configureAsserts;
tests = {
'path config': {
setup: configureSetup({
baseUrl: '',
paths: beget(curl_base.paths, {
'plainJane.js': 'stuff/plain_old.js',
'js!jane2.js': 'stuff/plain_old_2.js'
// TODO: more tests
})
}),
test: function (require, done) {
var tests;
tests = {
'should remap plugin-loaded resource': function (cb, assert) {
curl(['js!plainJane.js'])
.then(cb.success, cb.failure)
.then(done, done);
},
'should remap plugin-specific path': function (cb, assert) {
function checkExports (exports) {
assert.equal('ketchup', exports);
}
curl(['js!plainJane.js!order', 'js!jane2.js!order'])
.then(cb.success, cb.failure)
//.then(checkExports)
.then(done, done);
}
};
for (var name in tests) {
tests[name](
configureCallbacks(success, failure, name),
configureAsserts(success, failure, name)
);
}
}
}
};
curl(['curl/_privileged', 'curl/tdd/runner', 'curl/domReady', 'configureAsserts']).then(
function (priv, runner, ready, asserts) {
privateCfg = priv.cfg;
testRunner = runner;
domReady = ready;
configureAsserts = asserts;
}
).then(
function () {
for (var name in tests) {
testRunner(false, tests[name].setup).run(tests[name].test);
}
}
);
function configureSetup (config) {
return function setup () {
resetCurl();
curl(config);
};
}
function configureCallbacks (success, failure, msg) {
return {
success: function () { success(msg); },
failure: function () { failure(msg); }
};
}
function write (msg) {
domReady(function () {
document.body.appendChild(document.createElement('div')).innerHTML = msg;
})
}
function assertTrue (val, msg) { (val ? success: failure)(msg); }
function failure (msg, expected) { write('FAILED: ' + msg); }
function success (msg) { write('SUCCESS: ' + msg); }
function resetCurl () {
for (var name in privateCfg) {
delete privateCfg[name];
}
}
function beget (ancestor, props) {
function Begetter () {}
Begetter.prototype = ancestor;
var obj = new Begetter();
if (props) for (var p in props) obj[p] = props[p];
return obj;
}
}());
</script>
</head>
<body>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.