1 import partition from './partition';
3 describe('partition()', () => {
4 it('returns empty arrays if array is empty', () => {
5 const array: string[] = [];
6 const predicate = (item: string): item is string => {
7 return typeof item === 'string';
10 const result = partition(array, predicate);
12 expect(result).toStrictEqual([[], []]);
15 it('partitions items that fit the predicate into the first array', () => {
16 const array: any[] = ['string 0', 'string 1', 0, 1, undefined, null, 'string 2', 2, 'string 3'];
17 const predicate = (item: string): item is string => {
18 return typeof item === 'string';
21 const result = partition(array, predicate);
23 expect(result).toStrictEqual([
24 ['string 0', 'string 1', 'string 2', 'string 3'],
25 [0, 1, undefined, null, 2],