mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
merge: Add test case to Find Second Largest Element Algorithm (#1037)
This commit is contained in:
13
Sorts/test/FindSecondLargestElement.test.js
Normal file
13
Sorts/test/FindSecondLargestElement.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
import { secondLargestElement } from '../FindSecondLargestElement'
|
||||
|
||||
test('The second largest element of the array [1, 2, 3, 4, 5] is 4', () => {
|
||||
const array = [1, 2, 3, 4, 5]
|
||||
const res = secondLargestElement(array)
|
||||
expect(res).toEqual(4)
|
||||
})
|
||||
|
||||
test('The second largest element of the array [-1, -2, -3, -4, -5] is -2', () => {
|
||||
const array = [-1, -2, -3, -4, -5]
|
||||
const res = secondLargestElement(array)
|
||||
expect(res).toEqual(-2)
|
||||
})
|
Reference in New Issue
Block a user