Skip to content

Commit 989d881

Browse files
test(2020-day-07): revise tests for part 2 solution to cover expectations
1 parent 0bfdae1 commit 989d881

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

2020/day-7/bagRules.test.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ const testData = {
1313
'vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.',
1414
'faded blue bags contain no other bags.',
1515
'dotted black bags contain no other bags.'
16+
],
17+
part2Rules: [
18+
'shiny gold bags contain 2 dark red bags.',
19+
'dark red bags contain 2 dark orange bags.',
20+
'dark orange bags contain 2 dark yellow bags.',
21+
'dark yellow bags contain 2 dark green bags.',
22+
'dark green bags contain 2 dark blue bags.',
23+
'dark blue bags contain 2 dark violet bags.',
24+
'dark violet bags contain no other bags.'
1625
]
1726
}
1827

@@ -61,10 +70,15 @@ describe('--- Day 7: Handy Haversacks ---', () => {
6170
describe('Part 2', () => {
6271
describe('countInner()', () => {
6372
it('provides a list of child bags and with quantity of each', () => {
64-
const result = Object.keys(
73+
const result1 = Object.values(
6574
countInner(testData.rules.map(parseRule), 'shiny gold bag')
66-
).reduce((total, colorSubTotal) => total + colorSubTotal, 0)
67-
expect(result).to.equal(126)
75+
).reduce((a, b) => a + b, 0)
76+
expect(result1).to.equal(32)
77+
78+
const result2 = Object.values(
79+
countInner(testData.part2Rules.map(parseRule), 'shiny gold bag')
80+
).reduce((a, b) => a + b, 0)
81+
expect(result2).to.equal(126)
6882
})
6983
})
7084
})

0 commit comments

Comments
 (0)