-
Notifications
You must be signed in to change notification settings - Fork 1
/
separateAndSort.test.ts
33 lines (27 loc) · 979 Bytes
/
separateAndSort.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { separateAndSort } from './separateAndSort';
describe('#separateAndSort', () => {
it('should separate and sort even and odd numbers', () => {
expect(separateAndSort([4, 3, 2, 1, 5, 7, 8, 9])).toStrictEqual([
[2, 4, 8],
[1, 3, 5, 7, 9],
]);
});
it('should handle an array with all even numbers', () => {
expect(separateAndSort([2, 4, 6, 8, 10])).toStrictEqual([[2, 4, 6, 8, 10], []]);
});
it('should handle an array with all odd numbers', () => {
expect(separateAndSort([1, 3, 5, 7, 9])).toStrictEqual([[], [1, 3, 5, 7, 9]]);
});
it('should handle an empty array', () => {
expect(separateAndSort([])).toStrictEqual([[], []]);
});
it('should handle an array with zeros and negative numbers', () => {
expect(separateAndSort([0, -2, 4, -6, 0, 3, 5, 7, 9])).toStrictEqual([
[-6, -2, 4],
[3, 5, 7, 9],
]);
});
it('should handle an array with only zeros', () => {
expect(separateAndSort([0, 0, 0])).toStrictEqual([[], []]);
});
});