Files
lodash/test/lodash(...)-methods-that-return-new-wrapped-values.spec.ts
2023-09-16 16:18:43 -07:00

46 lines
1.1 KiB
TypeScript

import assert from 'node:assert';
import lodashStable from 'lodash';
describe('lodash(...) methods that return new wrapped values', () => {
const funcs = [
'castArray',
'concat',
'difference',
'differenceBy',
'differenceWith',
'intersection',
'intersectionBy',
'intersectionWith',
'pull',
'pullAll',
'pullAt',
'sampleSize',
'shuffle',
'slice',
'splice',
'split',
'toArray',
'union',
'unionBy',
'unionWith',
'uniq',
'uniqBy',
'uniqWith',
'words',
'xor',
'xorBy',
'xorWith',
];
lodashStable.each(funcs, (methodName) => {
it(`\`_(...).${methodName}\` should return a new wrapped value`, () => {
const value = methodName === 'split' ? 'abc' : [1, 2, 3],
wrapped = _(value),
actual = wrapped[methodName]();
assert.ok(actual instanceof _);
assert.notStrictEqual(actual, wrapped);
});
});
});