1 import groupWith from './groupWith';
3 describe('groupWith', () => {
4 it('groups items of an array into a two dimensional array based on a condition of whether or not two items should be grouped', () => {
5 expect(groupWith((a, b) => a === b, [1, 1, 1, 2, 2, 3])).toEqual([[1, 1, 1], [2, 2], [3]]);
8 it('defaults to use an empty array', () => {
9 expect(groupWith((a, b) => a === b)).toEqual([]);
12 it('returns an empty array if no items are provided in the to-be-grouped array', () => {
13 expect(groupWith((x) => x, [])).toEqual([]);
16 it('returns an empty array if no items pass the grouping condition', () => {
17 expect(groupWith(() => false, [1, 2, 3])).toEqual([]);