forked from EggDice/lets-code-bp-snake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.spec.js
49 lines (43 loc) · 886 Bytes
/
game.spec.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
'use strict'
import test from 'ava'
import gameFactory from './game.js'
test(t => {
const game = gameFactory(() => {})
const expected = {
direction: 'right',
body: [
[3, 0], [2, 0], [1, 0], [0, 0]
]
}
t.deepEqual(game.getSnake(), expected)
})
test(t => {
const game = gameFactory(() => {})
game.tick()
const expected = {
direction: 'right',
body: [
[4, 0], [3, 0], [2, 0], [1, 0]
]
}
t.deepEqual(game.getSnake(), expected)
})
test(t => {
const game = gameFactory((snakePoints) => {
const expected = [
[4, 0], [3, 0], [2, 0], [1, 0]
]
t.deepEqual(snakePoints, expected)
})
game.tick()
})
test(t => {
const game = gameFactory((snakePoints) => {
const expected = [
[3, 1], [3, 0], [2, 0], [1, 0]
]
t.deepEqual(snakePoints, expected)
})
game.onArrowEvent('bottom')
game.tick()
})