Skip to content

Commit 93a7aea

Browse files
test(2019-day-03): tests for wire crossings
1 parent 2b43e5a commit 93a7aea

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

2019/day-03/wires.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint-env mocha */
2+
const expect = require('chai').expect
3+
const { elfWireToSVGPath, findWireIntersections } = require('./wires')
4+
5+
describe('--- 2019 Day 3: Crossed Wires ---', () => {
6+
describe('Part 1', () => {
7+
describe('elfWiresToSVGPath()', () => {
8+
it('converts elfwire syntax to svg path syntax', () => {
9+
const wire = 'R75,D30,R83,U83,L12,D49,R71,U7,L72'
10+
const expected = 'M0,0 h75 v30 h83 v-83 h-12 v49 h71 v-7 h-72'
11+
const actual = elfWireToSVGPath(wire)
12+
expect(actual).to.equal(expected)
13+
})
14+
})
15+
describe('findWireIntersections()', () => {
16+
it('finds the intersection points of multiple wires', () => {
17+
const wires = [
18+
'R8,U5,L5,D3',
19+
'U7,R6,D4'
20+
]
21+
const expected = [
22+
[3, 3],
23+
[6, 9]
24+
]
25+
const actual = findWireIntersections(wires)
26+
expect(actual).to.deep.equal(expected)
27+
})
28+
})
29+
})
30+
})

0 commit comments

Comments
 (0)