Skip to content

Commit

Permalink
Update lib/arrays/splitArray.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Benji Grant <[email protected]>
  • Loading branch information
giraugh and GRA0007 authored Jul 19, 2023
1 parent 9732e39 commit ae350db
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/arrays/splitArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,15 @@ if (import.meta.vitest) {
const runs = splitArray([1, 3, 5, 6, 7, 9, 11], (x) => x % 2 === 0)
expect(runs).toEqual([[1, 3, 5], [7, 9, 11]])
})

it('handles an empty array', () => {
const runs = splitArray([], (x) => x === 0)
expect(runs).toEqual([])
})

it('works if predicate is always true', () => {
const runs = splitArray(['a', 'b', 'c'], () => true)
expect(runs).toEqual([[], [], [], []])
})

}

0 comments on commit ae350db

Please sign in to comment.