mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
wip: code formatting nits continued
This commit is contained in:
28
test/meanBy.spec.js
Normal file
28
test/meanBy.spec.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { slice } from './utils';
|
||||
import meanBy from '../src/meanBy';
|
||||
|
||||
describe('meanBy', () => {
|
||||
const objects = [{ a: 2 }, { a: 3 }, { a: 1 }];
|
||||
|
||||
it('should work with an `iteratee`', () => {
|
||||
const actual = meanBy(objects, (object) => object.a);
|
||||
|
||||
expect(actual).toEqual(2);
|
||||
});
|
||||
|
||||
it('should provide correct `iteratee` arguments', () => {
|
||||
let args;
|
||||
|
||||
meanBy(objects, function () {
|
||||
args || (args = slice.call(arguments));
|
||||
});
|
||||
|
||||
expect(args).toEqual([{ a: 2 }]);
|
||||
});
|
||||
|
||||
it('should work with `_.property` shorthands', () => {
|
||||
const arrays = [[2], [3], [1]];
|
||||
expect(meanBy(arrays, 0)).toBe(2);
|
||||
expect(meanBy(objects, 'a')).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user