Skip to content

Commit aa7ac4c

Browse files
committed
add find-2nd-max tests
1 parent e7f1166 commit aa7ac4c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/_Problems_/find-2nd-max/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ function findSecondMax(arr) {
2020
}
2121
return max2;
2222
}
23+
24+
module.exports = {
25+
findSecondMax,
26+
};
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const { findSecondMax } = require('.');
2+
3+
describe('FindSecondMax', () => {
4+
it('Should return 6', () => {
5+
expect(findSecondMax([9, 2, 3, 6])).toEqual(6);
6+
});
7+
8+
it('Should return -1', () => {
9+
expect(findSecondMax([0, -1, -2, 0])).toEqual(-1);
10+
});
11+
12+
it('Should return 0', () => {
13+
expect(findSecondMax([-2, -1, 0, 1])).toEqual(0);
14+
});
15+
});

0 commit comments

Comments
 (0)