mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Cleanup _.every and _.some tests.
This commit is contained in:
60
test/test.js
60
test/test.js
@@ -4314,6 +4314,12 @@
|
||||
QUnit.module('lodash.every');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should return `true` if `predicate` returns truthy for all elements', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.strictEqual(_.every([true, 1, 'a'], _.identity), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `true` for empty collections', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -4328,12 +4334,6 @@
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('should return `true` if `predicate` returns truthy for all elements in the collection', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.strictEqual(_.every([true, 1, 'a'], _.identity), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` as soon as `predicate` returns falsey', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -16694,6 +16694,13 @@
|
||||
QUnit.module('lodash.some');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should return `true` if `predicate` returns truthy for any element', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
assert.strictEqual(_.some([false, 1, ''], _.identity), true);
|
||||
assert.strictEqual(_.some([null, 'x', 0], _.identity), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` for empty collections', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -16708,14 +16715,7 @@
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('should return `true` if `predicate` returns truthy for any element in the collection', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
assert.strictEqual(_.some([false, 1, ''], _.identity), true);
|
||||
assert.strictEqual(_.some([null, 'x', 0], _.identity), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` if `predicate` returns falsey for all elements in the collection', function(assert) {
|
||||
QUnit.test('should return `false` if `predicate` returns falsey for all elements', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
assert.strictEqual(_.some([false, false, false], _.identity), false);
|
||||
@@ -16728,22 +16728,6 @@
|
||||
assert.strictEqual(_.some([null, true, null], _.identity), true);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.property" style `predicate`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var objects = [{ 'a': 0, 'b': 0 }, { 'a': 0, 'b': 1 }];
|
||||
assert.strictEqual(_.some(objects, 'a'), false);
|
||||
assert.strictEqual(_.some(objects, 'b'), true);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.matches" style `predicate`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var objects = [{ 'a': 0, 'b': 0 }, { 'a': 1, 'b': 1}];
|
||||
assert.strictEqual(_.some(objects, { 'a': 0 }), true);
|
||||
assert.strictEqual(_.some(objects, { 'b': 2 }), false);
|
||||
});
|
||||
|
||||
QUnit.test('should use `_.identity` when `predicate` is nullish', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
@@ -16766,6 +16750,22 @@
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.property" style `predicate`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var objects = [{ 'a': 0, 'b': 0 }, { 'a': 0, 'b': 1 }];
|
||||
assert.strictEqual(_.some(objects, 'a'), false);
|
||||
assert.strictEqual(_.some(objects, 'b'), true);
|
||||
});
|
||||
|
||||
QUnit.test('should work with a "_.matches" style `predicate`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var objects = [{ 'a': 0, 'b': 0 }, { 'a': 1, 'b': 1}];
|
||||
assert.strictEqual(_.some(objects, { 'a': 0 }), true);
|
||||
assert.strictEqual(_.some(objects, { 'b': 2 }), false);
|
||||
});
|
||||
|
||||
QUnit.test('should work as an iteratee for methods like `_.map`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user