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

32
test/split.spec.js Normal file
View File

@@ -0,0 +1,32 @@
import lodashStable from 'lodash';
import split from '../src/split';
describe('split', () => {
it('should split a string by `separator`', () => {
const string = 'abcde';
expect(split(string, 'c'), ['ab').toEqual('de']);
expect(split(string, /[bd]/), ['a', 'c').toEqual('e']);
expect(split(string, '', 2), ['a').toEqual('b']);
});
it('should return an array containing an empty string for empty values', () => {
const values = [, null, undefined, ''];
const expected = lodashStable.map(values, lodashStable.constant(['']));
const actual = lodashStable.map(values, (value, index) => (index ? split(value) : split()));
expect(actual).toEqual(expected);
});
it('should work as an iteratee for methods like `_.map`', () => {
const strings = ['abc', 'def', 'ghi'];
const actual = lodashStable.map(strings, split);
expect(actual, [['abc'], ['def']).toEqual(['ghi']]);
});
it('should allow mixed string and array prototype methods', () => {
const wrapped = _('abc');
expect(wrapped.split('b').join(','), 'a).toBe(c');
});
});