-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreeSum.test.js
More file actions
23 lines (18 loc) · 865 Bytes
/
Copy paththreeSum.test.js
File metadata and controls
23 lines (18 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const threeSum = require('./threeSum');
describe('Three Sum', () => {
it('should return the correct triplets', () => {
expect(threeSum([-1, 0, 1, 2, -1, -4])).toEqual(expect.arrayContaining([[-1, -1, 2], [-1, 0, 1]]));
});
it('should return an empty array when input array is empty', () => {
expect(threeSum([])).toEqual(expect.arrayContaining([]));
});
it('should return an empty array when input array has only one element', () => {
expect(threeSum([0])).toEqual(expect.arrayContaining([]));
});
it('should return the correct triplet when input array has all elements as zeros', () => {
expect(threeSum([0, 0, 0, 0])).toEqual(expect.arrayContaining([[0, 0, 0]]));
});
it('should return an empty array when no triplet sums to zero', () => {
expect(threeSum([1, 2, -2, -1])).toEqual(expect.arrayContaining([]));
});
});