-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
58 lines (56 loc) · 1.34 KB
/
index.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
50
51
52
53
54
55
56
57
58
// import {selectSleigh} from './index'
import {selectSleighOptimized as selectSleigh} from './index'
const cases = [
{
distance: 30,
sleights: [
{name: 'Dasher', consumption: 0.3},
{name: 'Dancer', consumption: 0.5},
{name: 'Rudolph', consumption: 0.7},
{name: 'Midu', consumption: 1},
],
expected: 'Dancer',
},
{
distance: 1,
sleights: [
{name: 'pheralb', consumption: 0.3},
{name: 'TMChein', consumption: 0.5},
],
expected: 'TMChein',
},
{
distance: 10,
sleights: [
{name: 'Pedrosillano', consumption: 1},
{name: 'SamarJaffal', consumption: 5},
],
expected: 'Pedrosillano',
},
{
distance: 10,
sleights: [
{name: 'Pedrosillano', consumption: 1},
{name: 'SamarJaffal', consumption: 2},
{name: 'marcospage', consumption: 3},
],
expected: 'SamarJaffal',
},
{
distance: 50,
sleights: [
{name: 'Pedrosillano', consumption: 1},
{name: 'SamarJaffal', consumption: 2},
{name: 'marcospage', consumption: 3},
],
expected: null,
},
]
describe('Day 12 challenge', () => {
it.each(cases)(
'selects $expected as the best sleight for custom sleights and distance $distance',
({distance, sleights, expected}) => {
expect(selectSleigh(distance, sleights)).toEqual(expected)
}
)
})