-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsolution.test.js
49 lines (31 loc) · 1.09 KB
/
solution.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const transformArray = require('./solution')
test('Example 1', () => {
const arr = [6, 2, 3, 4]
const result = transformArray(arr)
expect(result).toStrictEqual([6, 3, 3, 4])
})
test('Example 2', () => {
const arr = [1, 6, 3, 4, 3, 5]
const result = transformArray(arr)
expect(result).toStrictEqual([1, 4, 4, 4, 4, 5])
})
test('Array length 1, should return same thing', () => {
const arr = [5]
const result = transformArray(arr)
expect(result).toStrictEqual([5])
})
test('Array length 2, should return same thing', () => {
const arr = [5, 3]
const result = transformArray(arr)
expect(result).toStrictEqual([5, 3])
})
test('not bigger or smaller on both side, should return same thing', () => {
const arr = [1, 2, 2, 3, 3, 4]
const result = transformArray(arr)
expect(result).toStrictEqual([1, 2, 2, 3, 3, 4])
})
test('not bigger or smaller on both side, values higher than first and last element, should return same thing', () => {
const arr = [1, 55, 55, 33, 33, 10]
const result = transformArray(arr)
expect(result).toStrictEqual([1, 55, 55, 33, 33, 10])
})