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/jquery/jquery.js"></script>
<script src="../vendor/platform.js/platform.js"></script>
<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="../vendor/qunit/qunit/qunit.js"></script>
<script src="test-ui.js"></script>
<script src="../lodash.js"></script>
<script>

View File

@@ -8,13 +8,7 @@
<body>
<div id="qunit"></div>
<script src="../vendor/platform.js/platform.js"></script>
<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="../vendor/qunit/qunit/qunit.js"></script>
<script src="test-ui.js"></script>
<script>
// set a bad shim

View File

@@ -11,8 +11,13 @@
_ = require('../lodash.js');
/** The unit testing framework */
var QUnit = global.QUnit = require('../vendor/qunit/qunit/qunit.js');
require('../vendor/qunit-clib/qunit-clib.js');
var QUnit = (
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) */
var timeLimit = process.argv.reduce(function(result, value, index) {
@@ -37,7 +42,10 @@
'select': 'filter',
'tail': 'rest',
'take': 'first',
'unique': 'uniq'
'unique': 'uniq',
// method used by the `backbone` and `underscore` builds
'findWhere': 'find'
};
/** Used to associate real names with their aliases */
@@ -46,7 +54,7 @@
'contains': ['include'],
'every': ['all'],
'filter': ['select'],
'find': ['detect'],
'find': ['detect', 'findWhere'],
'first': ['head', 'take'],
'forEach': ['each'],
'functions': ['methods'],
@@ -263,7 +271,6 @@
'forOwn',
'isPlainObject',
'merge',
'partial',
'partialRight'
]));
@@ -797,7 +804,11 @@
strictEqual(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename);
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();
});
@@ -821,7 +832,6 @@
'forOwn',
'isPlainObject',
'merge',
'partial',
'partialRight'
], function(methodName) {
equal(lodash[methodName], undefined, '_.' + methodName + ' should not exist: ' + basename);
@@ -1188,4 +1198,8 @@
if (isFinite(timeLimit)) {
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 */
var QUnit =
window.QUnit || (
window.setTimeout || (window.addEventListener = window.setTimeout = / /),
window.QUnit = load('../vendor/qunit/qunit/qunit' + (platform.name == 'Narwhal' ? '-1.8.0' : '') + '.js') || window.QUnit,
window.addEventListener || (window.addEventListener = Function.prototype),
window.setTimeout || (window.setTimeout = Function.prototype),
window.QUnit = load('../vendor/qunit/qunit/qunit.js') || window.QUnit,
load('../vendor/qunit-clib/qunit-clib.js'),
(window.addEventListener || 0).test && delete window.addEventListener,
window.addEventListener === Function.prototype && delete window.addEventListener,
window.QUnit
);
/** The `lodash` function to test */
var _ = window._ || (
_ = load(filePath) || window._,
_._ || _
);
_ = load(filePath) || window._,
_._ || _
);
/** Used to pass falsey values to methods */
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');
(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) {
QUnit.start();
}

View File

@@ -21,13 +21,7 @@
</div>
<script src="../vendor/jquery/jquery.js"></script>
<script src="../vendor/platform.js/platform.js"></script>
<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="../vendor/qunit/qunit/qunit.js"></script>
<script src="test-ui.js"></script>
<script>
document.write('<script src="../' + ui.buildPath + '"><\/script>');
@@ -62,6 +56,10 @@
_.mixin(_);
_.mixin({
'findWhere': _.find
});
_.chain = function(value) {
value = new _(value);
value.__chain__ = true;

File diff suppressed because it is too large Load Diff