mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Add fp.findFrom and fp.findLastFrom tests.
This commit is contained in:
@@ -1097,9 +1097,9 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('fp.findIndexFrom methods');
|
||||
QUnit.module('fp.findFrom methods');
|
||||
|
||||
_.each(['findIndexFrom', 'findLastIndexFrom'], function(methodName) {
|
||||
_.each(['findFrom', 'findIndexFrom', 'findLastFrom', 'findLastIndexFrom'], function(methodName) {
|
||||
var func = fp[methodName];
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should provide the correct `predicate` arguments', function(assert) {
|
||||
@@ -1117,6 +1117,44 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('fp.findFrom');
|
||||
|
||||
(function() {
|
||||
function resolve(value) {
|
||||
return fp.flow(fp.property('a'), fp.eq(value));
|
||||
}
|
||||
|
||||
QUnit.test('should have an argument order of `value`, `fromIndex`, then `array`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var objects = [{ 'a': 1 }, { 'a': 2 }, { 'a': 1 }, { 'a': 2 }];
|
||||
|
||||
assert.strictEqual(fp.findFrom(resolve(1))(1)(objects), objects[2]);
|
||||
assert.strictEqual(fp.findFrom(resolve(2))(-2)(objects), objects[3]);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('fp.findLastFrom');
|
||||
|
||||
(function() {
|
||||
function resolve(value) {
|
||||
return fp.flow(fp.property('a'), fp.eq(value));
|
||||
}
|
||||
|
||||
QUnit.test('should have an argument order of `value`, `fromIndex`, then `array`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var objects = [{ 'a': 1 }, { 'a': 2 }, { 'a': 1 }, { 'a': 2 }];
|
||||
|
||||
assert.strictEqual(fp.findLastFrom(resolve(1))(1)(objects), objects[0]);
|
||||
assert.strictEqual(fp.findLastFrom(resolve(2))(-2)(objects), objects[1]);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('fp.findIndexFrom and fp.indexOfFrom');
|
||||
|
||||
_.each(['findIndexFrom', 'indexOfFrom'], function(methodName) {
|
||||
|
||||
Reference in New Issue
Block a user