index.html revision b47f230a8ee484efe376ea0ed2d1d3837e71f6c2
<!doctype html>
<html>
<head>
<title>RLS Testing</title>
</head>
<body>
<script src="/build/yui/yui.js"></script>
<script src="baz.js"></script>
<script>
var max = 11,
results = [];
var check = function() {
if (results.length === max) {
YUI({
use_rls: true,
rls_base: rls_base
}).use('test', function(Y) {
var s = new Y.Test.Suite("Dynamic Use");
var cases = {
name: 'Local RLS Tests'
};
Y.each(results, function(v) {
var name = v.name.replace(/ /g, '_').replace(/#/, '').toLowerCase();
cases[name] = (function(v) {
return function() {
Y.Assert.areEqual(0, v.missed.length, v.name + ' has missing LOADED modules: [' + Y.Object.keys(Y.Array.hash(v.missed)) + ']');
Y.Assert.areEqual(0, v.m, v.name + ' has missing ATTACHED modules');
};
})(v);
});
s.add(new Y.Test.Case(cases));
Y.Test.Runner.add(s);
Y.Test.Runner.run();
});
}
};
var has = function(str, Y, mod) {
var a = [], m = [];
if (!(mod instanceof Array)) {
mod = [mod];
}
for (var i = 0; i < mod.length; i++) {
var k = mod[i];
if (Y.Env._attached[k]) {
a.push(k);
} else {
m.push(k);
}
}
var res = {
name: 'Test ' + str,
missed: Y.Env._missed,
m: m
};
results.push(res);
check();
};
var rls_base = 'http://localhost:3000/load?';
YUI({
use_rls: true,
rls_base: rls_base
}).use('node', 'yql', function(Y) {
has('#1', Y, ['node', 'yql']);
});
YUI({
use_rls: true,
rls_base: rls_base
}).use('dd', function(Y) {
has('#2', Y, 'dd');
});
YUI({
use_rls: true,
rls_base: rls_base
}).use('yql', 'node', function(Y) {
has('#3', Y, ['yql', 'node']);
});
YUI({
use_rls: true,
rls_base: rls_base
}).use('node', function(Y) {
has('#4', Y, ['node']);
});
YUI({
use_rls: true,
rls_base: rls_base,
modules: {
foo: {
fullpath: 'foo.js',
requires: ['io-base']
},
bar: {
fullpath: 'bar.js',
requires: ['yql']
}
}
}).use('foo', function(Y) {
has('#5', Y, ['foo', 'io-base']);
});
YUI({
use_rls: true,
rls_base: rls_base,
modules: {
foo: {
fullpath: 'foo.js',
requires: ['io-base']
},
bar2: {
fullpath: 'bar2.js',
requires: ['yql', 'foo']
}
}
}).use('bar2', function(Y) {
//console.log('#6 keys:', Y.Object.keys(Y.Env._attached).sort());
has('#6', Y, ['bar2', 'yql', 'foo', 'io-base']);
});
YUI({
use_rls: true,
rls_base: rls_base,
modules: {
foo: {
fullpath: 'foo.js',
requires: ['io-base']
},
bar: {
fullpath: 'bar.js',
requires: ['yql', 'foo']
}
}
}).use('baz', function(Y) {
//console.log('#7 keys:', Y.Object.keys(Y.Env._attached).sort());
has('#7', Y, ['baz', 'console']);
});
YUI({
use_rls: true,
rls_base: rls_base
}).use('gallery-torelativetime', function(Y) {
//console.log('#8 keys:', Y.Object.keys(Y.Env._attached).sort());
has('#8', Y, ['gallery-torelativetime', 'loader-base']);
});
YUI({
use_rls: true,
rls_base: rls_base
}).use('autocomplete', function(Y) {
//console.log('#9 keys:', Y.Object.keys(Y.Env._attached).sort());
has('#9', Y, ['autocomplete-base', 'autocomplete-list', 'autocomplete-plugin']);
});
YUI({
use_rls: true,
rls_base: rls_base
}).use('widget', function(Y) {
//console.log('#10 keys:', Y.Object.keys(Y.Env._attached).sort());
has('#10', Y, ['widget', 'base-base']);
});
YUI({
use_rls: true,
rls_base: rls_base,
combine: true
}).use('yui2-datatable', 'dd', function(Y) {
//console.log('#11 keys:', Y.Object.keys(Y.Env._attached).sort());
has('#11', Y, ['dd', 'yui2-datatable']);
});
</script>
</body>
</html>