wip: code formatting nits continued

This commit is contained in:
jdalton
2023-09-16 22:59:56 -07:00
parent 0b28b7f7b6
commit b5c59317ea
421 changed files with 7354 additions and 9005 deletions

33
test/sum-methods.spec.js Normal file
View 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');
});
});
});