mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Expand test coverage.
This commit is contained in:
@@ -109,7 +109,9 @@
|
|||||||
if (!window._Float64Array) {
|
if (!window._Float64Array) {
|
||||||
setProperty(window, 'Float64Array', window.Uint8Array);
|
setProperty(window, 'Float64Array', window.Uint8Array);
|
||||||
}
|
}
|
||||||
|
setProperty(window, 'exports', window);
|
||||||
setProperty(window, 'global', window);
|
setProperty(window, 'global', window);
|
||||||
|
setProperty(window, 'module', {});
|
||||||
setProperty(window, 'WinRTError', Error);
|
setProperty(window, 'WinRTError', Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +160,9 @@
|
|||||||
document.createDocumentFragment = document._createDocumentFragment;
|
document.createDocumentFragment = document._createDocumentFragment;
|
||||||
setProperty(document, '_createDocumentFragment', undefined);
|
setProperty(document, '_createDocumentFragment', undefined);
|
||||||
|
|
||||||
|
setProperty(window, 'exports', undefined);
|
||||||
setProperty(window, 'global', undefined);
|
setProperty(window, 'global', undefined);
|
||||||
|
setProperty(window, 'module', undefined);
|
||||||
setProperty(window, 'WinRTError', undefined);
|
setProperty(window, 'WinRTError', undefined);
|
||||||
|
|
||||||
delete Array._isArray;
|
delete Array._isArray;
|
||||||
|
|||||||
54
test/test.js
54
test/test.js
@@ -623,13 +623,41 @@
|
|||||||
QUnit.module('lodash constructor');
|
QUnit.module('lodash constructor');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
var values = empties.concat(true, 1, 'a'),
|
||||||
|
expected = _.map(values, _.constant(true));
|
||||||
|
|
||||||
test('creates a new instance when called without the `new` operator', 1, function() {
|
test('creates a new instance when called without the `new` operator', 1, function() {
|
||||||
ok(_() instanceof _);
|
var actual = _.map(values, function(value) {
|
||||||
|
return _(value) instanceof _;
|
||||||
|
});
|
||||||
|
|
||||||
|
deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return provided `lodash` instances', 1,function() {
|
test('should return provided `lodash` instances', 1, function() {
|
||||||
var wrapped = _(false);
|
var actual = _.map(values, function(value) {
|
||||||
strictEqual(_(wrapped), wrapped);
|
var wrapped = _(value);
|
||||||
|
return _(wrapped) === wrapped;
|
||||||
|
});
|
||||||
|
|
||||||
|
deepEqual(actual, expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should convert foreign wrapped values to `lodash` instances', 1, function() {
|
||||||
|
if (lodashBizarro) {
|
||||||
|
var actual = _.map(values, function(value) {
|
||||||
|
var wrapped = _(lodashBizarro(value)),
|
||||||
|
unwrapped = wrapped.__wrapped__;
|
||||||
|
|
||||||
|
return wrapped instanceof _ &&
|
||||||
|
(unwrapped === value || (_.isNaN(unwrapped) && _.isNaN(value)));
|
||||||
|
});
|
||||||
|
|
||||||
|
deepEqual(actual, expected);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
@@ -1355,7 +1383,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should ensure the minimum `chunkSize` is `1`', 1, function() {
|
test('should ensure the minimum `chunkSize` is `1`', 1, function() {
|
||||||
var values = falsey.concat(-1),
|
var values = falsey.concat(-1, -Infinity),
|
||||||
expected = _.map(values, _.constant([[0], [1], [2], [3], [4], [5]]));
|
expected = _.map(values, _.constant([[0], [1], [2], [3], [4], [5]]));
|
||||||
|
|
||||||
var actual = _.map(values, function(value, index) {
|
var actual = _.map(values, function(value, index) {
|
||||||
@@ -1660,7 +1688,7 @@
|
|||||||
(function() {
|
(function() {
|
||||||
test('should create a function that always returns `value`', 1, function() {
|
test('should create a function that always returns `value`', 1, function() {
|
||||||
var object = { 'a': 1 },
|
var object = { 'a': 1 },
|
||||||
values = falsey.concat(null, null, 1, 'a'),
|
values = Array(2).concat(empties, true, 1, 'a'),
|
||||||
constant = _.constant(object),
|
constant = _.constant(object),
|
||||||
expected = _.map(values, function() { return true; });
|
expected = _.map(values, function() { return true; });
|
||||||
|
|
||||||
@@ -1682,8 +1710,10 @@
|
|||||||
var expected = _.map(falsey, function() { return true; });
|
var expected = _.map(falsey, function() { return true; });
|
||||||
|
|
||||||
var actual = _.map(falsey, function(value, index) {
|
var actual = _.map(falsey, function(value, index) {
|
||||||
var constant = index ? _.constant(value) : _.constant();
|
var constant = index ? _.constant(value) : _.constant(),
|
||||||
return constant() === value || _.isNaN(value);
|
result = constant();
|
||||||
|
|
||||||
|
return result === value || (_.isNaN(result) && _.isNaN(value));
|
||||||
});
|
});
|
||||||
|
|
||||||
deepEqual(actual, expected);
|
deepEqual(actual, expected);
|
||||||
@@ -4334,7 +4364,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should return `false` for primitives', 1, function() {
|
test('should return `false` for primitives', 1, function() {
|
||||||
var values = falsey.concat(1, 'a'),
|
var values = falsey.concat(true, 1, 'a'),
|
||||||
expected = _.map(values, _.constant(false));
|
expected = _.map(values, _.constant(false));
|
||||||
|
|
||||||
var actual = _.map(values, function(value) {
|
var actual = _.map(values, function(value) {
|
||||||
@@ -5960,7 +5990,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should return `false` for non objects', 1, function() {
|
test('should return `false` for non objects', 1, function() {
|
||||||
var values = falsey.concat('a', true),
|
var values = falsey.concat(true, 1, 'a'),
|
||||||
expected = _.map(values, _.constant(false));
|
expected = _.map(values, _.constant(false));
|
||||||
|
|
||||||
var actual = _.map(values, function(value, index) {
|
var actual = _.map(values, function(value, index) {
|
||||||
@@ -7430,7 +7460,7 @@
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
test('should always return `undefined`', 1, function() {
|
test('should always return `undefined`', 1, function() {
|
||||||
var values = falsey.concat([], true, new Date, _, {}, /x/, 'a'),
|
var values = empties.concat(true, new Date, _, 1, /x/, 'a'),
|
||||||
expected = _.map(values, _.constant());
|
expected = _.map(values, _.constant());
|
||||||
|
|
||||||
var actual = _.map(values, function(value, index) {
|
var actual = _.map(values, function(value, index) {
|
||||||
@@ -8759,7 +8789,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should return the specified default value for undefined properties', 1, function() {
|
test('should return the specified default value for undefined properties', 1, function() {
|
||||||
var values = falsey.concat(1, _.constant(1));
|
var values = empties.concat(true, new Date, _.constant(1), 1, /x/, 'a');
|
||||||
|
|
||||||
var expected = _.transform(values, function(result, value) {
|
var expected = _.transform(values, function(result, value) {
|
||||||
result.push(value, value);
|
result.push(value, value);
|
||||||
|
|||||||
Reference in New Issue
Block a user