mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
wip: migrate to bun
This commit is contained in:
35
test/stub-methods.spec.ts
Normal file
35
test/stub-methods.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import assert from 'node:assert';
|
||||
import lodashStable from 'lodash';
|
||||
import { _, empties } from './utils';
|
||||
|
||||
describe('stub methods', () => {
|
||||
lodashStable.each(
|
||||
['noop', 'stubTrue', 'stubFalse', 'stubArray', 'stubObject', 'stubString'],
|
||||
(methodName) => {
|
||||
const func = _[methodName];
|
||||
|
||||
const pair = {
|
||||
stubArray: [[], 'an empty array'],
|
||||
stubFalse: [false, '`false`'],
|
||||
stubObject: [{}, 'an empty object'],
|
||||
stubString: ['', 'an empty string'],
|
||||
stubTrue: [true, '`true`'],
|
||||
noop: [undefined, '`undefined`'],
|
||||
}[methodName];
|
||||
|
||||
const values = Array(2).concat(empties, true, 1, 'a'),
|
||||
expected = lodashStable.map(values, lodashStable.constant(pair[0]));
|
||||
|
||||
it(`\`_.${methodName}\` should return ${pair[1]}`, () => {
|
||||
const actual = lodashStable.map(values, (value, index) => {
|
||||
if (index < 2) {
|
||||
return index ? func.call({}) : func();
|
||||
}
|
||||
return func(value);
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user