mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 19:37:49 +00:00
wip: code formatting nits continued
This commit is contained in:
28
test/find-and-findLast.spec.js
Normal file
28
test/find-and-findLast.spec.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import lodashStable from 'lodash';
|
||||
import { _, LARGE_ARRAY_SIZE, square, isEven } from './utils';
|
||||
|
||||
describe('find and findLast', () => {
|
||||
lodashStable.each(['find', 'findLast'], (methodName) => {
|
||||
const isFind = methodName === 'find';
|
||||
|
||||
it(`\`_.${methodName}\` should support shortcut fusion`, () => {
|
||||
let findCount = 0;
|
||||
let mapCount = 0;
|
||||
const array = lodashStable.range(1, LARGE_ARRAY_SIZE + 1);
|
||||
|
||||
const iteratee = function (value) {
|
||||
mapCount++;
|
||||
return square(value);
|
||||
};
|
||||
const predicate = function (value) {
|
||||
findCount++;
|
||||
return isEven(value);
|
||||
};
|
||||
const actual = _(array).map(iteratee)[methodName](predicate);
|
||||
|
||||
expect(findCount).toBe(isFind ? 2 : 1);
|
||||
expect(mapCount).toBe(isFind ? 2 : 1);
|
||||
expect(actual).toBe(isFind ? 4 : square(LARGE_ARRAY_SIZE));
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user