Update tests to work with QUnit v1.11.0.

Former-commit-id: ce6d6fb1756eb606e8106ac7e93816dffb48624e
This commit is contained in:
John-David Dalton
2013-01-30 00:38:31 -08:00
parent 4907a7389f
commit 812b848daf
6 changed files with 46 additions and 1898 deletions

View File

@@ -21,13 +21,7 @@
<script src="../vendor/json3/lib/json3.js"></script> <script src="../vendor/json3/lib/json3.js"></script>
<script src="../vendor/jquery/jquery.js"></script> <script src="../vendor/jquery/jquery.js"></script>
<script src="../vendor/platform.js/platform.js"></script> <script src="../vendor/platform.js/platform.js"></script>
<script> <script src="../vendor/qunit/qunit/qunit.js"></script>
// avoid syntax errors for `QUnit.throws` in older Firefoxes
document.write(platform.name == 'Firefox' && /^1\b/.test(platform.version)
? '<script src="../vendor/qunit/qunit/qunit-1.8.0.js"><\/script>'
: '<script src="../vendor/qunit/qunit/qunit.js"><\/script>'
);
</script>
<script src="test-ui.js"></script> <script src="test-ui.js"></script>
<script src="../lodash.js"></script> <script src="../lodash.js"></script>
<script> <script>

View File

@@ -8,13 +8,7 @@
<body> <body>
<div id="qunit"></div> <div id="qunit"></div>
<script src="../vendor/platform.js/platform.js"></script> <script src="../vendor/platform.js/platform.js"></script>
<script> <script src="../vendor/qunit/qunit/qunit.js"></script>
// avoid syntax errors for `QUnit.throws` in older Firefoxes
document.write(platform.name == 'Firefox' && /^1\b/.test(platform.version)
? '<script src="../vendor/qunit/qunit/qunit-1.8.0.js"><\/script>'
: '<script src="../vendor/qunit/qunit/qunit.js"><\/script>'
);
</script>
<script src="test-ui.js"></script> <script src="test-ui.js"></script>
<script> <script>
// set a bad shim // set a bad shim

View File

@@ -11,8 +11,13 @@
_ = require('../lodash.js'); _ = require('../lodash.js');
/** The unit testing framework */ /** The unit testing framework */
var QUnit = global.QUnit = require('../vendor/qunit/qunit/qunit.js'); var QUnit = (
require('../vendor/qunit-clib/qunit-clib.js'); global.addEventListener || (global.addEventListener = Function.prototype),
global.QUnit = require('../vendor/qunit/qunit/qunit.js'),
load('../vendor/qunit-clib/qunit-clib.js'),
global.addEventListener === Function.prototype && delete global.addEventListener,
global.QUnit
);
/** The time limit for the tests to run (minutes) */ /** The time limit for the tests to run (minutes) */
var timeLimit = process.argv.reduce(function(result, value, index) { var timeLimit = process.argv.reduce(function(result, value, index) {
@@ -37,7 +42,10 @@
'select': 'filter', 'select': 'filter',
'tail': 'rest', 'tail': 'rest',
'take': 'first', 'take': 'first',
'unique': 'uniq' 'unique': 'uniq',
// method used by the `backbone` and `underscore` builds
'findWhere': 'find'
}; };
/** Used to associate real names with their aliases */ /** Used to associate real names with their aliases */
@@ -46,7 +54,7 @@
'contains': ['include'], 'contains': ['include'],
'every': ['all'], 'every': ['all'],
'filter': ['select'], 'filter': ['select'],
'find': ['detect'], 'find': ['detect', 'findWhere'],
'first': ['head', 'take'], 'first': ['head', 'take'],
'forEach': ['each'], 'forEach': ['each'],
'functions': ['methods'], 'functions': ['methods'],
@@ -263,7 +271,6 @@
'forOwn', 'forOwn',
'isPlainObject', 'isPlainObject',
'merge', 'merge',
'partial',
'partialRight' 'partialRight'
])); ]));
@@ -797,7 +804,11 @@
strictEqual(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename); strictEqual(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename);
var collection = [{ 'a': { 'b': 1, 'c': 2 } }]; var collection = [{ 'a': { 'b': 1, 'c': 2 } }];
deepEqual(lodash.where(collection, { 'a': { 'b': 1 } }), []); deepEqual(lodash.where(collection, { 'a': { 'b': 1 } }), [], '_.where performs shallow comparisons: ' + basename);
collection = [{ 'a': 1 }, { 'a': 1 }];
deepEqual(lodash.where(collection, { 'a': 1 }, true), collection[0], '_.where supports a `first` argument: ' + basename);
deepEqual(lodash.findWhere(collection, { 'a': 1 }), collection[0], '_.findWhere: ' + basename);
start(); start();
}); });
@@ -821,7 +832,6 @@
'forOwn', 'forOwn',
'isPlainObject', 'isPlainObject',
'merge', 'merge',
'partial',
'partialRight' 'partialRight'
], function(methodName) { ], function(methodName) {
equal(lodash[methodName], undefined, '_.' + methodName + ' should not exist: ' + basename); equal(lodash[methodName], undefined, '_.' + methodName + ' should not exist: ' + basename);
@@ -1188,4 +1198,8 @@
if (isFinite(timeLimit)) { if (isFinite(timeLimit)) {
setTimeout(process.exit, timeLimit * 6e4); setTimeout(process.exit, timeLimit * 6e4);
} }
// explicitly call `QUnit.start()` for Narwhal, Node.js, Rhino, and RingoJS
if (!global.document) {
QUnit.start();
}
}()); }());

View File

@@ -34,18 +34,19 @@
/** The unit testing framework */ /** The unit testing framework */
var QUnit = var QUnit =
window.QUnit || ( window.QUnit || (
window.setTimeout || (window.addEventListener = window.setTimeout = / /), window.addEventListener || (window.addEventListener = Function.prototype),
window.QUnit = load('../vendor/qunit/qunit/qunit' + (platform.name == 'Narwhal' ? '-1.8.0' : '') + '.js') || window.QUnit, window.setTimeout || (window.setTimeout = Function.prototype),
window.QUnit = load('../vendor/qunit/qunit/qunit.js') || window.QUnit,
load('../vendor/qunit-clib/qunit-clib.js'), load('../vendor/qunit-clib/qunit-clib.js'),
(window.addEventListener || 0).test && delete window.addEventListener, window.addEventListener === Function.prototype && delete window.addEventListener,
window.QUnit window.QUnit
); );
/** The `lodash` function to test */ /** The `lodash` function to test */
var _ = window._ || ( var _ = window._ || (
_ = load(filePath) || window._, _ = load(filePath) || window._,
_._ || _ _._ || _
); );
/** Used to pass falsey values to methods */ /** Used to pass falsey values to methods */
var falsey = [ var falsey = [
@@ -1862,6 +1863,16 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
QUnit.module('lodash.result');
(function() {
test('should return `undefined` when passed a falsey `object` argument', function() {
strictEqual(_.result(), undefined);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.rest'); QUnit.module('lodash.rest');
(function() { (function() {
@@ -2699,7 +2710,7 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
// explicitly call `QUnit.start()` for Narwhal, Rhino, and RingoJS // explicitly call `QUnit.start()` for Narwhal, Node.js, Rhino, and RingoJS
if (!window.document) { if (!window.document) {
QUnit.start(); QUnit.start();
} }

View File

@@ -21,13 +21,7 @@
</div> </div>
<script src="../vendor/jquery/jquery.js"></script> <script src="../vendor/jquery/jquery.js"></script>
<script src="../vendor/platform.js/platform.js"></script> <script src="../vendor/platform.js/platform.js"></script>
<script> <script src="../vendor/qunit/qunit/qunit.js"></script>
// avoid syntax errors for `QUnit.throws` in older Firefoxes
document.write(platform.name == 'Firefox' && /^1\b/.test(platform.version)
? '<script src="../vendor/qunit/qunit/qunit-1.8.0.js"><\/script>'
: '<script src="../vendor/qunit/qunit/qunit.js"><\/script>'
);
</script>
<script src="test-ui.js"></script> <script src="test-ui.js"></script>
<script> <script>
document.write('<script src="../' + ui.buildPath + '"><\/script>'); document.write('<script src="../' + ui.buildPath + '"><\/script>');
@@ -62,6 +56,10 @@
_.mixin(_); _.mixin(_);
_.mixin({
'findWhere': _.find
});
_.chain = function(value) { _.chain = function(value) {
value = new _(value); value = new _(value);
value.__chain__ = true; value.__chain__ = true;

File diff suppressed because it is too large Load Diff