Skip to content

Commit 8761287

Browse files
test(2018 day-15): Stub in unit tests for the cave system
1 parent 59f4ea4 commit 8761287

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

2018/day-15/caves.test.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* eslint-env mocha */
2+
const expect = require('chai').expect
3+
const {
4+
Cave
5+
} = require('./recipes')
6+
7+
describe('--- Day 15: Beverage Bandits ---', () => {
8+
describe('Part 1:', () => {
9+
describe('new Cave()', () => {
10+
it('initializes a cave with elves and goblins', () => {
11+
const test = `
12+
#######
13+
#.G.E.#
14+
#E.G.E#
15+
#.G.E.#
16+
#######
17+
`
18+
const cave = new Cave(test)
19+
expect(cave.rounds).to.equal(0)
20+
expect(cave.outcome).to.equal(null)
21+
expect(cave.filter((unit) => unit.type === 'elves').length).to.equal(4)
22+
expect(cave.filter((unit) => unit.type === 'goblins').length).to.equal(3)
23+
expect(cave.filter((unit) => unit.type === 'elves')[0].location).to.deep.equal([5, 1])
24+
expect(cave.filter((unit) => unit.type === 'goblins')[3].location).to.deep.equal([2, 3])
25+
expect(cave.map[4][4]).to.equal('#')
26+
expect(cave.map[3][4]).to.equal('.')
27+
})
28+
describe('advance()', () => {
29+
it('advances the cave combat cycle', () => {
30+
31+
})
32+
})
33+
describe('findPath(origin, target)', () => {
34+
it('determines a path from the origin to the target', () => {
35+
36+
})
37+
it('returns null when the path is blocked by cave', () => {
38+
39+
})
40+
it('returns null when the path is blocked by other units', () => {
41+
42+
})
43+
})
44+
describe('display()', () => {
45+
it('renders the current cave state', () => {
46+
47+
})
48+
})
49+
})
50+
describe('new Unit()', () => {
51+
it('initializes an elf or a goblin', () => {
52+
const expected = { hp: 200, ap: 3, location: [3, 4] }
53+
})
54+
describe('attack()', () => {
55+
it('attacks the closest oponent', () => {
56+
57+
})
58+
})
59+
describe('findClosestOponent()', () => {
60+
it('finds the unit\'s closest oponent', () => {
61+
62+
})
63+
})
64+
describe('move()', () => {
65+
it('moves the unit towards the closest oponent', () => {
66+
const test = `
67+
#######
68+
#.E...#
69+
#.....#
70+
#...G.#
71+
#######`
72+
const expected = [3, 1]
73+
const cave = new Cave(test)
74+
cave.units[0].move()
75+
const actual = cave.units[0].location
76+
expect(actual).to.deep.equal(expected)
77+
})
78+
})
79+
})
80+
})
81+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy