Permalink
Browse files

Rearranging some Tests for Node.js testing

  • Loading branch information...
1 parent c55726d commit 8350852c5ae1c3f604f1e1dbce26541300565908 @davglass davglass committed Apr 20, 2012
@@ -1,5 +1,5 @@
YUI.add('mod', function(Y) {
Y.MOD = true;
}, '', {
- requires: [ 'node', 'yql' ]
+ requires: [ 'yql' ]
});
@@ -0,0 +1,32 @@
+YUI.add('browser-tests', function(Y) {
+
+ var suite = new Y.Test.Suite('Core Browser Tests');
+
+ suite.add(new Y.Test.Case({
+ test_attach_after: function() {
+ var Assert = Y.Assert;
+ YUI.add('after-test', function(Y) {
+ Y.afterTest = true;
+ Assert.isObject(Y.Node, 'Node not loaded before this module');
+ }, '1.0.0', {
+ after: [ 'node' ]
+ });
+
+ YUI().use('after-test', function(Y2) {
+ Assert.isTrue(Y2.afterTest, 'after-test module was not loaded');
+ });
+ },
+ test_rollup_false: function() {
+ var Assert = Y.Assert;
+ YUI().use('dd', function(Y) {
+ Assert.isUndefined(Y.Env._attached.dd, 'DD Alias Module was attached');
+ });
+ YUI().use('node', function(Y) {
+ Assert.isUndefined(Y.Env._attached.node, 'Node Alias Module was attached');
+ });
+ }
+ });
+
+ Y.Test.Runner.add(suite);
+
+});
@@ -1,17 +1,37 @@
YUI.add('config-test', function(Y) {
+
+
var testCore = new Y.Test.Case({
name: "Config tests",
-
- test_config: function() {
+ _should: {
+ error: {
+ 'test: YUI_config': (Y.UA.nodejs ? true : false)
+ }
+ },
+
+ 'test: YUI_config': function() {
+ Y.Assert.isObject(YUI_config);
Y.Assert.areEqual(YUI_config.gfilter, Y.config.filter);
- Y.Assert.isObject(Y.config.logExclude);
Y.Assert.isTrue(Y.config.gconfig);
- YUI().use('node', function(Y2) {
+
+ YUI().use('oop', function(Y2) {
Y.Assert.isUndefined(Y2.config.logExclude);
Y.Assert.isUndefined(Y2.config.filter);
Y.Assert.isTrue(Y2.config.gconfig);
});
+ },
+
+ 'test: local config': function() {
+ Y.Assert.isObject(Y.config.logExclude);
+ },
+
+ test_config: function() {
+ YUI().use('oop', function(Y2) {
+ Y.Assert.isUndefined(Y2.config.logExclude);
+ Y.Assert.isUndefined(Y2.config.filter);
+ Y.Assert.isTrue(Y2.config.globalConfig);
+ });
var o1 = { a: 1 };
var o2 = { b: 1 };
@@ -20,9 +40,9 @@ YUI.add('config-test', function(Y) {
var o5 = { e: 1 };
var o6 = { f: 1 };
- YUI(o1, o2, o3, o4, o5, o6).use('node', function(Y2) {
+ YUI(o1, o2, o3, o4, o5, o6).use('oop', function(Y2) {
Y.Assert.areEqual(1, Y2.config.f);
- Y.Assert.isTrue(Y2.config.gconfig);
+ Y.Assert.isTrue(Y2.config.globalConfig);
});
}
});
@@ -34,6 +34,17 @@ YUI.add('core-tests', function(Y) {
};
/* }}} */
+ YUI.GlobalConfig = YUI.GlobalConfig || {};
+ YUI.GlobalConfig.useSync = true;
+
+ var resolvePath = function(p) {
+ if (Y.UA.nodejs) {
+ var path = require('path');
+ p = path.join(__dirname, p);
+ }
+ return p;
+ };
+
var testCore = new Y.Test.Case({
name: "Core tests",
@@ -43,8 +54,9 @@ YUI.add('core-tests', function(Y) {
test_attach_error_errFn: true
},
ignore: {
- 'getLocation() should return the location object': Y.UA.nodejs,
- 'getLocation() should return `undefined` when executing in node.js': (!Y.UA.nodejs || (Y.UA.nodejs && Y.config.win)) //If there is a window object, ignore too
+ 'getLocation() should return the location object': (Y.UA.nodejs ? true : false),
+ 'getLocation() should return `null` when executing in node.js': (!Y.UA.nodejs || (Y.UA.nodejs && Y.config.win)), //If there is a window object, ignore too
+ test_log_params: (typeof console == "undefined" || !console.info || Y.UA.nodejs)
}
},
@@ -110,8 +122,8 @@ YUI.add('core-tests', function(Y) {
Y.Assert.areSame(Y.config.win.location, Y.getLocation(), 'Did not return Y.config.win.location.');
},
- 'getLocation() should return `undefined` when executing in node.js': function () {
- Y.Assert.isUndefined(Y.getLocation(), 'Did not return `undefined`');
+ 'getLocation() should return `null` when executing in node.js': function () {
+ Y.Assert.isNull(Y.getLocation(), 'Did not return `null`');
},
test_cached_undefined_null: function() {
@@ -158,16 +170,16 @@ YUI.add('core-tests', function(Y) {
},
test_use_array: function() {
var Assert = Y.Assert;
- YUI().use(['dd', 'node'], function(Y) {
- Assert.isObject(Y.DD, 'DD was not loaded');
- Assert.isObject(Y.Node, 'Node was not loaded');
+ YUI().use(['yui-throttle', 'oop'], function(Y) {
+ Assert.isObject(Y.throttle, 'Throttle was not loaded');
+ Assert.isObject(Y.each, 'OOP was not loaded');
});
},
test_use_strings: function() {
var Assert = Y.Assert;
- YUI().use('dd', 'node', function(Y) {
- Assert.isObject(Y.DD, 'DD was not loaded');
- Assert.isObject(Y.Node, 'Node was not loaded');
+ YUI().use('yui-throttle', 'oop', function(Y) {
+ Assert.isObject(Y.throttle, 'Throttle was not loaded');
+ Assert.isObject(Y.each, 'OOP was not loaded');
});
},
test_one_submodule: function() {
@@ -177,7 +189,7 @@ YUI.add('core-tests', function(Y) {
'something':{
'submodules':{
'something1':{
- fullpath: './assets/sub.js'
+ fullpath: resolvePath('./assets/sub.js')
}
}
}
@@ -186,15 +198,6 @@ YUI.add('core-tests', function(Y) {
Assert.isTrue(Y.something1);
});
},
- test_rollup_false: function() {
- var Assert = Y.Assert;
- YUI().use('dd', function(Y) {
- Assert.isUndefined(Y.Env._attached.dd, 'DD Alias Module was attached');
- });
- YUI().use('node', function(Y) {
- Assert.isUndefined(Y.Env._attached.node, 'Node Alias Module was attached');
- });
- },
test_base_path: function() {
var Assert = Y.Assert;
for (var i in core_urls) {
@@ -253,15 +256,15 @@ YUI.add('core-tests', function(Y) {
YUI.applyConfig({
modules: {
davglass: {
- fullpath: './assets/davglass.js'
+ fullpath: resolvePath('./assets/davglass.js')
}
}
});
YUI.applyConfig({
modules: {
foo: {
- fullpath: './assets/foo.js'
+ fullpath: resolvePath('./assets/foo.js')
}
}
});
@@ -306,7 +309,7 @@ YUI.add('core-tests', function(Y) {
var Assert = Y.Assert,
test = this;
- YUI().use('global-mod', function(Y) {
+ YUI({useSync: false }).use('global-mod', function(Y) {
test.resume(function() {
Assert.isTrue(Y.GlobalMod, 'Module in global config failed to load');
});
@@ -380,10 +383,10 @@ YUI.add('core-tests', function(Y) {
},
test_attach_error: function() {
- /*
- As of 3.6.0 this should now throw an error as the default
- setting throwFail: false will supress the error #2531679
- */
+ //
+ // As of 3.6.0 this should now throw an error as the default
+ // setting throwFail: false will supress the error #2531679
+ //
var Assert = Y.Assert;
YUI.add('attach-error', function() { Y.push(); });
@@ -395,10 +398,10 @@ YUI.add('core-tests', function(Y) {
}).use('attach-error');
},
test_attach_error_silent: function() {
- /*
- As of 3.6.0 this should NOT throw an error as
- setting throwFail: false will supress the error #2531679
- */
+ //
+ // As of 3.6.0 this should NOT throw an error as
+ // setting throwFail: false will supress the error #2531679
+ //
var Assert = Y.Assert;
YUI.add('attach-error', function() { Y.push(); });
@@ -411,11 +414,11 @@ YUI.add('core-tests', function(Y) {
}).use('attach-error');
},
test_attach_error_errFn: function() {
- /*
- As of 3.6.0 this should throw an error as
- setting throwFail: false will supress the error and
- errorFn returns false see #2531679
- */
+ //
+ // As of 3.6.0 this should throw an error as
+ // setting throwFail: false will supress the error and
+ // errorFn returns false see #2531679
+ //
var Assert = Y.Assert;
YUI.add('attach-error', function() { Y.push(); });
@@ -427,19 +430,6 @@ YUI.add('core-tests', function(Y) {
}
}).use('attach-error');
},
- test_attach_after: function() {
- var Assert = Y.Assert;
- YUI.add('after-test', function(Y) {
- Y.afterTest = true;
- Assert.isObject(Y.Node, 'Node not loaded before this module');
- }, '1.0.0', {
- after: [ 'node' ]
- });
-
- YUI().use('after-test', function(Y2) {
- Assert.isTrue(Y2.afterTest, 'after-test module was not loaded');
- });
- },
test_dump_core: function() {
var Assert = Y.Assert,
o = {},
@@ -470,15 +460,15 @@ YUI.add('core-tests', function(Y) {
Assert = Y.Assert;
YUI({
+ useSync: false,
modules: {
mod: {
- fullpath: './assets/mod.js'
+ fullpath: resolvePath('./assets/mod.js')
}
}
}).use('mod', function(Y) {
test.resume(function() {
Assert.isTrue(Y.MOD, 'Failed to load external mod');
- Assert.isObject(Y.Node, 'Failed to load Node requirement');
Assert.isObject(Y.YQL, 'Failed to load YQL requirement');
});
});
@@ -41,6 +41,7 @@
<script type="text/javascript">
YUI.GlobalConfig = {
+ globalConfig: true,
modules: {
'global-mod': {
fullpath: './assets/globalmod.js'
@@ -100,6 +101,9 @@
'later-test': {
fullpath: 'later-test.js'
},
+ 'browser-tests': {
+ fullpath: 'browser-tests.js'
+ },
'namespace-test': {
fullpath: 'namespace-test.js'
@@ -41,6 +41,7 @@
<script type="text/javascript">
YUI.GlobalConfig = {
+ globalConfig: true,
modules: {
'global-mod': {
fullpath: './assets/globalmod.js'
@@ -99,6 +100,9 @@
fullpath: 'later-test.js'
},
+ 'browser-tests': {
+ fullpath: 'browser-tests.js'
+ },
'namespace-test': {
fullpath: 'namespace-test.js'
},
@@ -12,6 +12,7 @@
<script type="text/javascript">
YUI.GlobalConfig = {
+ globalConfig: true,
modules: {
'global-mod': {
fullpath: './assets/globalmod.js'
@@ -35,6 +36,9 @@
fullpath: './seed-tests.js',
requires: [ 'test']
},
+ 'browser-tests': {
+ fullpath: 'browser-tests.js'
+ },
'core-tests': {
fullpath: './core-tests.js',
requires: [ 'classnamemanager']
@@ -13,6 +13,7 @@
<script type="text/javascript">
YUI.GlobalConfig = {
+ globalConfig: true,
modules: {
'global-mod': {
fullpath: './assets/globalmod.js'
@@ -36,6 +37,9 @@
fullpath: './seed-tests.js',
requires: [ 'test']
},
+ 'browser-tests': {
+ fullpath: 'browser-tests.js'
+ },
'core-tests': {
fullpath: './core-tests.js',
requires: [ 'classnamemanager']
View
@@ -17,6 +17,7 @@
<script type="text/javascript">
YUI.GlobalConfig = {
+ globalConfig: true,
modules: {
'global-mod': {
fullpath: './assets/globalmod.js'
@@ -62,6 +63,9 @@
fullpath: 'later-test.js'
},
+ 'browser-tests': {
+ fullpath: 'browser-tests.js'
+ },
'namespace-test': {
fullpath: 'namespace-test.js'
}
@@ -3,6 +3,12 @@ YUI.add('later-test', function(Y) {
Y.SeedTests.add(new Y.Test.Case({
name: "Later tests",
+ _should: {
+ ignore: {
+ "test later(10, null, callback)": (Y.UA.nodejs ? true : false),
+ "test later(10, null, callback, null, true)": (Y.UA.nodejs ? true : false)
+ }
+ },
"test later(10, null, callback)": function() {
var test = this,
Oops, something went wrong.

0 comments on commit 8350852

Please sign in to comment.