mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Reorganize tests.
Former-commit-id: 5293cdc1206af20824e8aec86b892afd4badf639
This commit is contained in:
26
test/test.js
26
test/test.js
@@ -378,11 +378,12 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
QUnit.module('strict mode checks');
|
||||||
|
|
||||||
_.each(['bindAll', 'defaults', 'extend'], function(methodName) {
|
_.each(['bindAll', 'defaults', 'extend'], function(methodName) {
|
||||||
var func = _[methodName];
|
var func = _[methodName];
|
||||||
QUnit.module('lodash.' + methodName + ' strict mode checks');
|
|
||||||
|
|
||||||
test('should not throw strict mode errors', function() {
|
test('lodash.' + methodName + ' should not throw strict mode errors', function() {
|
||||||
var object = { 'a': null, 'b': function(){} },
|
var object = { 'a': null, 'b': function(){} },
|
||||||
pass = true;
|
pass = true;
|
||||||
|
|
||||||
@@ -517,17 +518,18 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
QUnit.module('object iteration bugs');
|
||||||
|
|
||||||
_.each(['forEach', 'forIn', 'forOwn'], function(methodName) {
|
_.each(['forEach', 'forIn', 'forOwn'], function(methodName) {
|
||||||
var func = _[methodName];
|
var func = _[methodName];
|
||||||
QUnit.module('lodash.' + methodName + ' iteration bugs');
|
|
||||||
|
|
||||||
test('fixes the JScript [[DontEnum]] bug (test in IE < 9)', function() {
|
test('lodash.' + methodName + ' fixes the JScript [[DontEnum]] bug (test in IE < 9)', function() {
|
||||||
var keys = [];
|
var keys = [];
|
||||||
func(shadowed, function(value, key) { keys.push(key); });
|
func(shadowed, function(value, key) { keys.push(key); });
|
||||||
deepEqual(keys.sort(), shadowedKeys);
|
deepEqual(keys.sort(), shadowedKeys);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('skips the prototype property of functions (test in Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1)', function() {
|
test('lodash.' + methodName + ' skips the prototype property of functions (test in Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1)', function() {
|
||||||
function Foo() {}
|
function Foo() {}
|
||||||
Foo.prototype.a = 1;
|
Foo.prototype.a = 1;
|
||||||
|
|
||||||
@@ -544,11 +546,14 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
QUnit.module('exit early');
|
||||||
|
|
||||||
_.each(['forEach', 'forIn', 'forOwn'], function(methodName) {
|
_.each(['forEach', 'forIn', 'forOwn'], function(methodName) {
|
||||||
var func = _[methodName];
|
var func = _[methodName];
|
||||||
QUnit.module('lodash.' + methodName + ' can exit early');
|
|
||||||
|
|
||||||
test('can exit early when iterating arrays', function() {
|
test('lodash.' + methodName + ' can exit early when iterating arrays', function() {
|
||||||
var array = [1, 2, 3],
|
var array = [1, 2, 3],
|
||||||
values = [];
|
values = [];
|
||||||
|
|
||||||
@@ -556,7 +561,7 @@
|
|||||||
deepEqual(values, [1]);
|
deepEqual(values, [1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can exit early when iterating objects', function() {
|
test('lodash.' + methodName + ' can exit early when iterating objects', function() {
|
||||||
var object = { 'a': 1, 'b': 2, 'c': 3 },
|
var object = { 'a': 1, 'b': 2, 'c': 3 },
|
||||||
values = [];
|
values = [];
|
||||||
|
|
||||||
@@ -798,6 +803,8 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
QUnit.module('isType checks');
|
||||||
|
|
||||||
_.each([
|
_.each([
|
||||||
'isArguments',
|
'isArguments',
|
||||||
'isArray',
|
'isArray',
|
||||||
@@ -817,9 +824,8 @@
|
|||||||
'isUndefined'
|
'isUndefined'
|
||||||
], function(methodName) {
|
], function(methodName) {
|
||||||
var func = _[methodName];
|
var func = _[methodName];
|
||||||
QUnit.module('lodash.' + methodName + ' result');
|
|
||||||
|
|
||||||
test('should return a boolean', function() {
|
test('lodash.' + methodName + ' should return a boolean', function() {
|
||||||
var expected = 'boolean';
|
var expected = 'boolean';
|
||||||
|
|
||||||
equal(typeof func(arguments), expected);
|
equal(typeof func(arguments), expected);
|
||||||
|
|||||||
Reference in New Issue
Block a user