mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
lodash: Rename to lodash and update support files. [jddalton]
This commit is contained in:
75
test/test.js
Normal file
75
test/test.js
Normal file
@@ -0,0 +1,75 @@
|
||||
(function(window, undefined) {
|
||||
|
||||
/** Use a single load function */
|
||||
var load = typeof require == 'function' ? require : window.load;
|
||||
|
||||
/** The unit testing framework */
|
||||
var QUnit =
|
||||
window.QUnit || (
|
||||
window.setTimeout || (window.addEventListener = window.setTimeout = / /),
|
||||
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.QUnit
|
||||
);
|
||||
|
||||
/** The `lodash` function to test */
|
||||
var _ =
|
||||
window._ || (
|
||||
_ = load('../lodash.js') || window._,
|
||||
_._ || _
|
||||
);
|
||||
|
||||
/** Shortcut used to convert array-like objects to arrays */
|
||||
var slice = [].slice;
|
||||
|
||||
/** Used to resolve a value's internal [[Class]] */
|
||||
var toString = {}.toString;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Skips a given number of tests with a passing result.
|
||||
*
|
||||
* @private
|
||||
* @param {Number} count The number of tests to skip.
|
||||
*/
|
||||
function skipTest(count) {
|
||||
while (count--) {
|
||||
ok(true, 'test skipped');
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// must explicitly use `QUnit.module` instead of `module()`
|
||||
// in case we are in a CLI environment
|
||||
QUnit.module('lodash');
|
||||
|
||||
(function() {
|
||||
test('supports loading lodash.js as a module', function() {
|
||||
if (window.document && window.require) {
|
||||
equal((_2 || {}).VERSION, _.VERSION);
|
||||
} else {
|
||||
skipTest(1)
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash constructor');
|
||||
|
||||
(function() {
|
||||
test('creates a new instance when called without the `new` operator', function() {
|
||||
ok(_() instanceof _);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// explicitly call `QUnit.start()` in a CLI environment
|
||||
if (!window.document) {
|
||||
QUnit.start();
|
||||
}
|
||||
}(typeof global == 'object' && global || this));
|
||||
Reference in New Issue
Block a user