1
YUI.add('core-tests', function(Y) {
3
/* {{{ Core URL Tests */
5
'http://localhost/build/yui/yui.js': { path: 'http://localhost/build/', filter: undefined },
6
'http://localhost/build/yui/yui-debug.js': { path: 'http://localhost/build/', filter: 'debug' },
7
'http://localhost/build/yui-base/yui-base.js': { path: 'http://localhost/build/', filter: undefined },
8
'http://localhost/build/yui-base/yui-base-debug.js': { path: 'http://localhost/build/', filter: 'debug' },
9
'http://localhost/build/yui-rls/yui-rls.js': { path: 'http://localhost/build/', filter: undefined },
10
'http://localhost/build/yui-rls/yui-rls-debug.js': { path: 'http://localhost/build/', filter: 'debug' },
11
'http://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js': { path: 'http://combohost.com/combo?/build/', filter: undefined },
12
'http://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js': { path: 'http://combohost.com/combo?/build/', filter: 'debug' },
13
'http://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js&build/loader/loader.js': { path: 'http://combohost.com/combo?/build/', filter: undefined },
14
'http://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js&buid/loader/loader.js': { path: 'http://combohost.com/combo?/build/', filter: 'debug' },
15
'https://localhost/build/yui/yui.js': { path: 'https://localhost/build/', filter: undefined },
16
'https://localhost/build/yui/yui-debug.js': { path: 'https://localhost/build/', filter: 'debug' },
17
'https://localhost/build/yui-base/yui-base.js': { path: 'https://localhost/build/', filter: undefined },
18
'https://localhost/build/yui-base/yui-base-debug.js': { path: 'https://localhost/build/', filter: 'debug' },
19
'https://localhost/build/yui-rls/yui-rls.js': { path: 'https://localhost/build/', filter: undefined },
20
'https://localhost/build/yui-rls/yui-rls-debug.js': { path: 'https://localhost/build/', filter: 'debug' },
21
'https://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js': { path: 'https://combohost.com/combo?/build/', filter: undefined },
22
'https://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js': { path: 'https://combohost.com/combo?/build/', filter: 'debug' },
23
'https://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js&build/loader/loader.js': { path: 'https://combohost.com/combo?/build/', filter: undefined },
24
'https://combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js&buid/loader/loader.js': { path: 'https://combohost.com/combo?/build/', filter: 'debug' },
26
'/build/yui/yui.js': { path: '/build/', filter: undefined },
27
'/build/yui/yui-debug.js': { path: '/build/', filter: 'debug' },
28
'/build/yui-base/yui-base.js': { path: '/build/', filter: undefined },
29
'/build/yui-base/yui-base-debug.js': { path: '/build/', filter: 'debug' },
30
'/build/yui-rls/yui-rls.js': { path: '/build/', filter: undefined },
31
'/build/yui-rls/yui-rls-debug.js': { path: '/build/', filter: 'debug' },
32
'build/simpleyui/simpleyui.js': { path: 'build/', filter: undefined },
33
'build/simpleyui/simpleyui-debug.js': { path: 'build/', filter: 'debug' },
34
'build/yui/yui.js': { path: 'build/', filter: undefined },
35
'build/yui/yui-debug.js': { path: 'build/', filter: 'debug' },
36
'build/yui-rls/yui-rls.js': { path: 'build/', filter: undefined },
37
'build/yui-rls/yui-rls-debug.js': { path: 'build/', filter: 'debug' },
38
'//combohost.com/combo?foo/foo.js&bar-bar.js&/build/simpleyui/simpleyui.js&build/loader/loader.js': { path: '//combohost.com/combo?/build/', filter: undefined },
39
'//combohost.com/combo?foo/foo.js&bar-bar.js&/build/simpleyui/simpleyui-debug.js&buid/oop/oop.js': { path: '//combohost.com/combo?/build/', filter: 'debug' },
40
'//combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base.js': { path: '//combohost.com/combo?/build/', filter: undefined },
41
'//combohost.com/combo?foo/foo.js&bar-bar.js&/build/yui-base/yui-base-debug.js': { path: '//combohost.com/combo?/build/', filter: 'debug' }
45
var testCore = new Y.Test.Case({
49
'cached functions should execute only once per input': function() {
51
var r1 = "", r2 = "", r3 = "";
53
var f1 = function(a) {
56
var c1 = Y.cached(f1);
65
Y.Assert.areEqual('ab', r1);
67
var f2 = function(a, b) {
70
var c2 = Y.cached(f2);
79
var o = new Y.EventTarget();
82
var f3 = function(a) {
83
Y.Assert.areEqual(1, this.foo);
87
var c3 = Y.cached(Y.bind(f3, o), {
98
Y.Assert.areEqual('b', r3);
100
// falsy second arg needs to produce a different key than no second arg
101
var cn = Y.ClassNameManager.getClassName;
102
Y.Assert.areEqual('yui3-a-', cn('a', ''));
103
Y.Assert.areEqual('yui3-a', cn('a'));
107
test_cached_undefined_null: function() {
109
var f1 = function(a) {
112
var c1 = Y.cached(f1);
115
Y.Assert.areEqual(a, null);
117
Y.Assert.areEqual(a, undefined);
119
Y.Assert.areEqual(a, 'foo');
123
test_ie_enum_bug: function() {
125
valueOf: function() {
131
Y.Assert.areEqual('foo', p.valueOf());
133
test_guid: function() {
135
for (i = 0; i < 1000; i++) {
138
Y.Assert.areNotEqual(id, id2, 'GUID creation failed, ids match');
141
test_stamp: function() {
143
for (i = 0; i < 1000; i++) {
146
Y.Assert.areNotEqual(id, id2, 'STAMP GUID creation failed, ids match');
149
test_use_array: function() {
150
var Assert = Y.Assert;
151
YUI().use(['dd', 'node'], function(Y) {
152
Assert.isObject(Y.DD, 'DD was not loaded');
153
Assert.isObject(Y.Node, 'Node was not loaded');
156
test_use_strings: function() {
157
var Assert = Y.Assert;
158
YUI().use('dd', 'node', function(Y) {
159
Assert.isObject(Y.DD, 'DD was not loaded');
160
Assert.isObject(Y.Node, 'Node was not loaded');
163
test_one_submodule: function() {
164
var Assert = Y.Assert;
170
fullpath: './assets/sub.js'
175
}).use('something1', function(Y) {
176
Assert.isTrue(Y.something1);
179
test_rollup_false: function() {
180
var Assert = Y.Assert;
181
YUI().use('dd', function(Y) {
182
Assert.isUndefined(Y.Env._attached.dd, 'DD Alias Module was attached');
184
YUI().use('node', function(Y) {
185
Assert.isUndefined(Y.Env._attached.node, 'Node Alias Module was attached');
188
test_base_path: function() {
189
var Assert = Y.Assert;
190
for (var i in core_urls) {
191
var info = Y.Env.parseBasePath(i, Y.Env._BASE_RE);
192
Assert.areSame(info.path, core_urls[i].path, 'Paths do not match (' + core_urls[i].path + ')');
193
//This test is assuming that IE returns an undefined, but it actually returns an empty string for the property
194
//Assert.areSame(info.filter, core_urls[i].filter, 'Filters do not match (' + core_urls[i].path + ')');
197
test_log_params: function() {
198
if (typeof console == "undefined" || !console.info) {
201
var l = console.info,
205
console.info = function(str) {
206
last = str.split(':')[0];
209
YUI().use(function (Y) {
210
Y.config.logInclude = {
215
Y.log('test logInclude logMe','info','logMe');
216
Assert.areEqual(last, 'logMe', 'logInclude (true) Failed');
219
Y.log('test logInclude butNotMe','info','butNotMe');
220
Assert.isUndefined(last, 'logInclude (false) Failed');
222
Y.config.logInclude = '';
223
Y.config.logExclude = {
225
butDontExcludeMe: false
227
Y.log('test logExclude excludeMe','info','excludeMe');
228
Assert.isUndefined(last, 'excludeInclude (true) Failed');
229
Y.log('test logExclude butDontExcludeMe','info','butDontExcludeMe');
230
Assert.areEqual(last, 'butDontExcludeMe', 'logExclue (false) Failed');
235
test_loader_combo_sep: function() {
236
var Assert = Y.Assert;
243
var loader = new testY.Loader(testY.config);
244
testY.Env._loader = loader;
246
testY.Get.script = function(s) {
248
Assert.isTrue((url.indexOf(testY.config.comboSep) > 5), 'Combo seperator (' + testY.config.comboSep + ') was not used');
249
testY._loading = false;
253
test_multiple_ua: function() {
254
var Assert = Y.Assert,
255
globalUA = YUI.Env.UA,
256
uaFF = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0) Gecko/20100101 Firefox/6.0',
257
uaChrome = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.860.0 Safari/535.2';
260
Assert.areEqual(globalUA.userAgent, Y1.UA.userAgent, 'Global UA and local (Y1) UA are different');
262
var parsed = YUI.Env.parseUA(uaChrome);
263
Assert.areEqual(parsed.userAgent, uaChrome, 'Parsed UA not equal Chrome');
264
Assert.isTrue((parsed.chrome > 0), 'Parsed UA not equal Chrome');
267
Assert.areEqual(globalUA.userAgent, Y2.UA.userAgent, 'Global UA and local (Y2) UA are different');
270
Assert.areEqual(YUI.Env.UA.userAgent, Y2.UA.userAgent, 'Global UA and local (Y2) UA are different');
275
Y.SeedTests.add(testCore);