loader-tests.js revision 43253d61bdc8b59163e74a0cafa7fa484203cfa4
var jsFailure = !((ua.ie && ua.ie < 9) || (ua.opera && ua.opera < 11.6) || (ua.webkit && ua.webkit < 530.17));
name: "Loader Tests",
_should: {
ignore: {
'test_failure': !jsFailure,
'test_timeout': !jsFailure
}
},
test_resolve_no_calc: function() {
ignoreRegistered: true,
});
},
test_resolve_manual_calc: function() {
ignoreRegistered: true,
});
},
test_resolve_auto_calc: function() {
ignoreRegistered: true,
});
},
test_resolve_combo: function() {
combine: true,
ignoreRegistered: true,
});
},
test_resolve_filter_debug: function() {
filter: 'debug',
combine: true,
ignoreRegistered: true,
});
},
test_resolve_filter_min: function() {
filter: 'min',
combine: true,
ignoreRegistered: true,
});
},
test_resolve_filter_raw: function() {
filter: 'raw',
combine: true,
ignoreRegistered: true,
});
},
test_resolve_combo_sep: function() {
comboSep: '==!!==',
combine: true,
ignoreRegistered: true,
});
},
test_resolve_combo_sep_group: function() {
comboSep: '==!!==',
combine: true,
ignoreRegistered: true,
require: ['foo'],
groups: {
extra: {
combine: true,
comboSep: '==;;==',
root: '',
base: '',
modules: {
foo: {
},
bar: {
requires: ['dd']
}
}
}
}
});
},
test_resolve_maxurl_length: function() {
maxURLLength: 1024,
combine: true,
ignoreRegistered: true,
});
},
test_resolve_maxurl_length_higher: function() {
maxURLLength: 8024,
combine: true,
ignoreRegistered: true,
});
},
test_resolve_maxurl_length_too_low: function() {
maxURLLength: 14,
combine: true,
ignoreRegistered: true,
require: ['oop']
});
},
test_resolve_maxurl_length_group: function() {
combine: true,
ignoreRegistered: true,
require: ['foo'],
groups: {
extra: {
combine: true,
maxURLLength: 45,
root: '',
base: '',
modules: {
foo: {
},
bar: {
requires: ['dd']
}
}
}
}
});
},
test_resolve_filters: function() {
combine: true,
ignoreRegistered: true,
});
},
test_group_filters: function() {
var test = this;
YUI({
debug: true,
filter: 'DEBUG',
groups: {
local: {
filter: 'raw',
combine: false,
base: './assets/',
modules: {
foo: {
requires: [ 'oop' ]
}
}
}
}
}).use('foo', function(Y) {
});
});
},
/* Commenting out until bug #2531436 get's completed.
test_module_attrs: function() {
var test = this;
YUI({
modules: {
'attrs-js': {
jsAttributes: {
id: 'attrs-js-test'
}
},
'attrs-css': {
type: 'css',
cssAttributes: {
id: 'attrs-css-test'
}
}
}
}).use('attrs-js', 'attrs-css', 'node', function(Y) {
test.resume(function() {
Assert.isTrue(Y.davglass, 'Attrs JS did not load');
Assert.isNotNull(Y.one('#attrs-js-test'), 'attrs-js-test id was not found');
Assert.isNotNull(Y.one('#attrs-css-test'), 'attrs-css-test id was not found');
});
});
test.wait();
},
*/
test_iter: function() {
var test = this;
YUI({
filter: 'debug',
gallery: 'gallery-2010.08.04-19-46',
'2in3': '4',
'yui2': '2.9.0'
Y.LOADED = true;
});
YUI({
filter: 'debug',
gallery: 'gallery-2010.08.04-19-46',
'2in3': '4',
'yui2': '2.9.0'
Y.LOADED = true;
});
});
},
test_progress: function() {
var test = this,
counter = 0;
YUI({
'2in3': '4',
'yui2': '2.9.0',
onSuccess: function(e) {
},
onProgress: function(e) {
proContext = this;
counter++;
}
},
Y.LOADED = true;
});
});
},
test_failure: function() {
var test = this,
fMsg;
YUI({
onFailure: function(e) {
fMsg = e;
},
modules: {
'bogus-module': {
}
}
}).use('bogus-module', function(Y) {
var e = fMsg;
});
});
},
test_timeout: function() {
var test = this,
fMsg;
YUI({
timeout: 1,
onTimeout: function(e) {
fMsg = e;
},
modules: {
'bogus-module': {
}
}
}).use('bogus-module', function(Y) {
var e = fMsg;
});
});
},
test_condpattern: function() {
var test = this;
YUI({
groups: {
testpatterns: {
patterns: {
modtest: {
return (mname === 'mod')
},
}
}
}
}
}
}).use('mod', function(Y) {
});
});
},
test_cond_with_test_function: function() {
var test = this;
YUI({
modules: {
cond2: {
condition: {
trigger: 'jsonp',
test: function() {
return true;
}
}
}
}
}).use('jsonp', function(Y) {
});
});
},
test_cond_no_test_or_ua: function() {
var test = this;
YUI({
modules: {
cond: {
condition: {
trigger: 'yql'
}
}
}
}).use('yql', function(Y) {
});
});
},
test_css_stamp: function() {
var test = this,
links = document.getElementsByTagName('link').length + document.getElementsByTagName('style').length;
var links2 = document.getElementsByTagName('link').length + document.getElementsByTagName('style').length;
});
});
},
test_forcemap: function() {
var test = this;
ignoreRegistered: true,
force : ['yui-base'],
require : ['json']
});
},
test_global_mods: function() {
var conf = {
combine: false,
require: ['widget-base'],
ignoreRegistered: true // force loader to include modules already on the page
},
Assert.areEqual(mods1.css.length, mods2.css.length, 'CSS Modules are not equal in 2 loader instances');
},
test_skin_default: function() {
Assert.areSame(loader.skin.defaultSkin, Y.Env.meta.skin.defaultSkin, 'Default skin was not set from default');
},
test_skin_string: function() {
skin: 'night'
});
},
test_skin_object: function() {
skin: {
defaultSkin: 'foobar'
}
});
},
test_skin_overrides: function() {
skin: {
overrides: {
slider: [
'sam',
'sam-dark',
'round',
'round-dark',
'capsule',
'capsule-dark',
'audio',
'audio-light'
]
}
},
require: [ 'slider' ]
});
Assert.areSame(loader.skin.overrides.slider.length, out.css.length, 'Failed to load all override skins');
},
test_load_optional: function() {
loadOptional: true,
ignoreRegistered: true,
require: [ 'dd-plugin' ]
});
var hasOptional = false;
hasOptional = true;
}
});
},
test_outside_group: function() {
combine: true,
ignoreRegistered: true,
require: [ 'gallery-calendar' ],
groups: {
mygallery: {
base:'./js/yui-library/',
combine:true,
comboBase: '/yui/?',
root:'yui-library/',
modules: {
'gallery-calendar':{
}
}
},
outside: {
combine:false,
modules:{
'calendar-skin': {
fullpath: '/css/calendar-skin.css',
type:'css'
}
}
}
}
});
},
test_outside_nocombine: function() {
combine: false,
ignoreRegistered: true,
require: [ 'gallery-calendar' ],
groups: {
mygallery: {
base:'./js/yui-library/',
combine:true,
comboBase: '/yui/?',
root:'yui-library/',
modules: {
'gallery-calendar':{
requires: [ 'gallery-calendar2' ]
},
'gallery-calendar2':{
requires: [ 'gallery-calendar3' ]
},
'gallery-calendar3':{
}
}
}
}
});
},
test_submodules: function() {
ignoreRegistered: true,
combine: false,
root: '',
base: '',
filter: 'raw',
modules: {
sub1: {
submodules: {
subsub1: {
},
subsub2: {
lang: 'en',
skinnable: true
}
}
}
},
require: [ 'subsub2' ]
});
Assert.areSame('sub1/lang/subsub2.js', out.js[0], 'Failed to combine submodule with module path for LANG JS');
Assert.areSame('sub1/assets/skins/sam/subsub2.css', out.css[0], 'Failed to combine submodule with module path CSS');
},
test_plugins: function() {
ignoreRegistered: true,
combine: false,
root: '',
base: '',
filter: 'raw',
modules: {
plug1: {
plugins: {
subplug1: {
lang: 'en',
skinnable: true
},
subplug2: {
lang: 'en',
skinnable: true,
requires: [ 'subplug1' ]
}
}
}
},
require: [ 'subplug2' ]
});
Assert.areSame('plug1/lang/subplug2.js', out.js[0], 'Failed to combine plugin with module path LANG JS');
Assert.areSame('plug1/lang/subplug1.js', out.js[1], 'Failed to combine plugin with module path LANG JS');
Assert.areSame('plug1/assets/skins/sam/subplug1.css', out.css[0], 'Failed to combine plugin with module path CSS');
Assert.areSame('plug1/assets/skins/sam/subplug2.css', out.css[1], 'Failed to combine plugin with module path CSS');
}
});
});