mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 17:50:39 +08:00
merge: Create firstRelativeMaxPointInArray.js (#772)
* Create first_relative_max_point_in_array.js go over randomly generated array and print first spike or maximum point index in it runs in O(log(n)) * rename file to match requested casing * add comments I prefer SOLID standards so that's why didn't add them at first but due to the repository requirements was needed to be added * remove template unrelated comments * Update equals check to match JavaScript standards * create file skafolding and adjust filename to reflect main function * using newer node version * add tests * add last line as empty line * style changes * move algorithm tests to test folder * revert to old package lock file * chore: add ending line feed Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com>
This commit is contained in:
29
Data-Structures/Array/test/LocalMaximomPoint.test.js
Normal file
29
Data-Structures/Array/test/LocalMaximomPoint.test.js
Normal file
@ -0,0 +1,29 @@
|
||||
import { LocalMaximomPoint } from '../LocalMaximomPoint'
|
||||
|
||||
describe('LocalMaximomPoint tests', () => {
|
||||
it('test boundry maximom points - last element', () => {
|
||||
const Array = [1, 2, 3, 4, 5, 6, 12]
|
||||
expect(LocalMaximomPoint(Array)).toEqual(6)
|
||||
})
|
||||
|
||||
it('test boundry maximom points - first element', () => {
|
||||
const Array2 = [13, 6, 5, 4, 3, 2, 1]
|
||||
expect(LocalMaximomPoint(Array2)).toEqual(0)
|
||||
})
|
||||
|
||||
it('test boundry maximom points - should find first maximom point from the top', () => {
|
||||
// Test a mix of number types (i.e., positive/negative, numbers with decimals, fractions)
|
||||
const Array = [13, 2, 3, 4, 5, 6, 12]
|
||||
expect(LocalMaximomPoint(Array)).toEqual(6)
|
||||
})
|
||||
|
||||
it('test inner points - second element', () => {
|
||||
const Array2 = [13, 16, 5, 4, 3, 2, 1]
|
||||
expect(LocalMaximomPoint(Array2)).toEqual(1)
|
||||
})
|
||||
|
||||
it('test inner points - element some where in the middle', () => {
|
||||
const Array2 = [13, 16, 5, 41, 3, 2, 1]
|
||||
expect(LocalMaximomPoint(Array2)).toEqual(3)
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user