/
index.test.js
43 lines (41 loc) · 976 Bytes
/
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
import {carryGifts} from './index'
const cases = [
{
gifts: ['game', 'bike', 'book', 'toy'],
maxWeight: 10,
expected: ['game bike', 'book toy'],
},
{
gifts: ['game', 'bike', 'book', 'toy'],
maxWeight: 7,
expected: ['game', 'bike', 'book toy'],
},
{
gifts: ['game', 'bike', 'book', 'toy'],
maxWeight: 4,
expected: ['game', 'bike', 'book', 'toy'],
},
{
gifts: ['toy', 'gamme', 'toy', 'bike'],
maxWeight: 6,
expected: ['toy', 'gamme', 'toy', 'bike'],
},
{
gifts: ['toy', 'toy', 'toy', 'toy'],
maxWeight: 2,
expected: [],
},
{
gifts: ['toy', 'toy', 'disk', 'disk', 'toy', 'toy'],
maxWeight: 7,
expected: ['toy toy', 'disk', 'disk toy', 'toy'],
},
]
describe('Day 17 challenge', () => {
it.each(cases)(
'groups the gifts $gifts in bags of $maxWeight max weight',
({gifts, maxWeight, expected}) => {
expect(carryGifts(gifts, maxWeight)).toEqual(expected)
}
)
})