mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
wip: migrate to bun
This commit is contained in:
34
test/sum-methods.spec.ts
Normal file
34
test/sum-methods.spec.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import assert from 'node:assert';
|
||||
import lodashStable from 'lodash';
|
||||
import { _, empties, stubZero } from './utils';
|
||||
|
||||
describe('sum methods', () => {
|
||||
lodashStable.each(['sum', 'sumBy'], (methodName) => {
|
||||
const array = [6, 4, 2],
|
||||
func = _[methodName];
|
||||
|
||||
it(`\`_.${methodName}\` should return the sum of an array of numbers`, () => {
|
||||
assert.strictEqual(func(array), 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));
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
it(`\`_.${methodName}\` should skip \`undefined\` values`, () => {
|
||||
assert.strictEqual(func([1, undefined]), 1);
|
||||
});
|
||||
|
||||
it(`\`_.${methodName}\` should not skip \`NaN\` values`, () => {
|
||||
assert.deepStrictEqual(func([1, NaN]), NaN);
|
||||
});
|
||||
|
||||
it(`\`_.${methodName}\` should not coerce values to numbers`, () => {
|
||||
assert.strictEqual(func(['1', '2']), '12');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user