-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.test.js
49 lines (45 loc) · 1.17 KB
/
utils.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
/* eslint-env jest */
const {
comparatorAscending,
comparatorDescending
} = require('./utils')
const positiveCasesAscending = [
[5, 18, true],
['John', 'Kevin', true],
[false, true, true],
[18, 5, false],
['Kevin', 'John', false],
[true, false, false],
[5, 5, false],
['John', 'John', false],
[true, true, false],
[false, false, false]
]
const positiveCasesDescending = [
[5, 18, false],
['John', 'Kevin', false],
[false, true, false],
[18, 5, true],
['Kevin', 'John', true],
[true, false, true],
[5, 5, false],
['John', 'John', false],
[true, true, false],
[false, false, false]
]
describe('Ascending order of arguments (a < b)', () => {
test.each(positiveCasesAscending)(
'comparing %p with %p should result in %p',
(argumentA, argumentB, expectedResult) => {
expect(comparatorAscending(argumentA, argumentB)).toEqual(expectedResult)
}
)
})
describe('Descending order of arguments (a > b)', () => {
test.each(positiveCasesDescending)(
'comparing %p with %p should result in %p',
(argumentA, argumentB, expectedResult) => {
expect(comparatorDescending(argumentA, argumentB)).toEqual(expectedResult)
}
)
})