-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrapState.test.js
More file actions
70 lines (62 loc) · 2.3 KB
/
bootstrapState.test.js
File metadata and controls
70 lines (62 loc) · 2.3 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const BootstrapState = require('./bootstrapState')
const t = require('./testHelpers')
function WaitingState() {
return {
// eslint-disable-next-line no-unused-vars
print: jest.fn((chat) => {}),
}
}
const room = 'room'
test('I can send messages', () => {
const waitingState = WaitingState()
const bootstrapState = BootstrapState(
'name',
'room',
'dealerName',
'smallBlindName',
'bigBlindName',
15,
[
{ id: 'id', cards: ['1', '2'], moneyLeft: 10 },
{ id: 'id2', cards: ['1', '2'], moneyLeft: 20 },
],
waitingState
)
const chat = t.Chat()
bootstrapState.print(chat)
expect(chat.game.mock.calls.length).toBe(6)
expect(chat.game.mock.calls[0][0]).toBe(room)
expect(chat.game.mock.calls[0][1]).toBe('Game in room room has started by name')
expect(chat.game.mock.calls[1][0]).toBe(room)
expect(chat.game.mock.calls[1][1]).toBe('The dealer is dealerName')
expect(chat.game.mock.calls[2][0]).toBe(room)
expect(chat.game.mock.calls[2][1]).toBe('The small blind is smallBlindName')
expect(chat.game.mock.calls[3][0]).toBe(room)
expect(chat.game.mock.calls[3][1]).toBe('The big blind is bigBlindName')
expect(chat.game.mock.calls[4][0]).toBe(room)
expect(chat.game.mock.calls[4][1]).toBe('Current pool prize is: 15')
expect(chat.game.mock.calls[5][1]).toBe('Dealing cards...')
expect(waitingState.print.mock.calls.length).toBe(1)
expect(chat.toSelf.mock.calls.length).toBe(2)
expect(chat.toSelf.mock.calls[0][0]).toBe('id')
expect(chat.toSelf.mock.calls[0][1]).toBe('Your hand is 1,2')
expect(chat.toSelf.mock.calls[1][0]).toBe('id2')
expect(chat.toSelf.mock.calls[1][1]).toBe('Your hand is 1,2')
expect(chat.toSelfInTopic.mock.calls.length).toBe(2)
expect(chat.toSelfInTopic.mock.calls[0][0]).toBe('id')
expect(chat.toSelfInTopic.mock.calls[0][1]).toEqual({
cards: ['1', '2'],
poolPrize: 15,
moneyLeft: 10,
})
expect(chat.toSelfInTopic.mock.calls[1][0]).toBe('id2')
expect(chat.toSelfInTopic.mock.calls[1][1]).toEqual({
cards: ['1', '2'],
poolPrize: 15,
moneyLeft: 20,
})
expect(chat.toRoomInTopic.mock.calls.length).toBe(1)
expect(chat.toRoomInTopic.mock.calls[0][0]).toBe(room)
expect(chat.toRoomInTopic.mock.calls[0][1]).toBe('')
expect(chat.toRoomInTopic.mock.calls[0][2]).toBe('update-common-cards')
})