|
1 | 1 | const { nextGreaterElement } = require('.');
|
2 | 2 |
|
3 | 3 | describe('Next greater element', () => {
|
4 |
| - it('returns next greater elements collection', () => { |
5 |
| - const input = [4, 6, 3, 2, 8, 1] |
6 |
| - const greaterElements = [6, 8, 8, 8, -1, -1] |
| 4 | + it('Should returns next greater elements collection', () => { |
| 5 | + const input = [4, 11, 6, 3, 2, 8, 1]; |
| 6 | + const greaterElements = [11, -1, 8, 8, 8, -1, -1]; |
7 | 7 |
|
8 | 8 | expect(nextGreaterElement(input)).toEqual(greaterElements);
|
9 | 9 | });
|
10 | 10 |
|
11 |
| - it('returns and empty collection for an empty array', () => { |
| 11 | + it('Should returns and empty collection for an empty array', () => { |
12 | 12 | expect(nextGreaterElement([])).toEqual([]);
|
13 | 13 | });
|
14 | 14 |
|
15 |
| - it('returns an array with -1 if the input has only one element', () => { |
| 15 | + it('Should returns an array with -1 if the input has only one element', () => { |
16 | 16 | expect(nextGreaterElement([0])).toEqual([-1]);
|
17 | 17 | });
|
18 | 18 |
|
19 |
| - it('returns a collection of -1 if there is no greater element', () => { |
20 |
| - const input = [90, 40, 15, 7, -1, -10] |
21 |
| - const greaterElements = [-1, -1, -1, -1, -1, -1] |
| 19 | + it('Should returns a collection of -1 if there is no greater element', () => { |
| 20 | + const input = [90, 40, 15, 7, -1, -10]; |
| 21 | + const greaterElements = [-1, -1, -1, -1, -1, -1]; |
22 | 22 |
|
23 | 23 | expect(nextGreaterElement(input)).toEqual(greaterElements);
|
24 | 24 | });
|
25 | 25 |
|
26 |
| - it('uses -1 if the numbers are the same', () => { |
27 |
| - const input = [90, 90] |
28 |
| - const greaterElements = [-1, -1] |
| 26 | + it('Should uses -1 if the numbers are the same', () => { |
| 27 | + const input = [90, 90]; |
| 28 | + const greaterElements = [-1, -1]; |
29 | 29 |
|
30 | 30 | expect(nextGreaterElement(input)).toEqual(greaterElements);
|
31 | 31 | });
|
32 | 32 |
|
33 |
| - it('throws an error if the input is not an array', () => { |
| 33 | + it('Should throws an error if the input is not an array', () => { |
34 | 34 | expect(() => {
|
35 |
| - nextGreaterElement('xunda') |
| 35 | + nextGreaterElement('xunda'); |
36 | 36 | }).toThrowError('Invalid Argument');
|
37 | 37 | });
|
38 | 38 | });
|
0 commit comments