mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
wip: code formatting nits continued
This commit is contained in:
33
test/sum-methods.spec.js
Normal file
33
test/sum-methods.spec.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import lodashStable from 'lodash';
|
||||
import { _, empties, stubZero } from './utils';
|
||||
|
||||
describe('sum methods', () => {
|
||||
lodashStable.each(['sum', 'sumBy'], (methodName) => {
|
||||
const array = [6, 4, 2];
|
||||
const func = _[methodName];
|
||||
|
||||
it(`\`_.${methodName}\` should return the sum of an array of numbers`, () => {
|
||||
expect(func(array)).toBe(12);
|
||||
});
|
||||
|
||||
it(`\`_.${methodName}\` should return \`0\` when passing empty \`array\` values`, () => {
|
||||
const expected = lodashStable.map(empties, stubZero);
|
||||
|
||||
const actual = lodashStable.map(empties, (value) => func(value));
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it(`\`_.${methodName}\` should skip \`undefined\` values`, () => {
|
||||
expect(func([1, undefined])).toBe(1);
|
||||
});
|
||||
|
||||
it(`\`_.${methodName}\` should not skip \`NaN\` values`, () => {
|
||||
expect(func([1, NaN])).toEqual(NaN);
|
||||
});
|
||||
|
||||
it(`\`_.${methodName}\` should not coerce values to numbers`, () => {
|
||||
expect(func(['1', '2'])).toBe('12');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user