-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallState.test.js
More file actions
30 lines (25 loc) · 1.14 KB
/
callState.test.js
File metadata and controls
30 lines (25 loc) · 1.14 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
const CallState = require('./callState')
const WaitingState = require('./waitingState')
const t = require('./testHelpers')
test('I can print the message', () => {
const room = 'room'
const callState = CallState('name2', room, WaitingState(room, 'name'), 10, 25, {
money: 33,
id: 'id2',
})
const chat = t.Chat()
callState.print(chat)
expect(chat.game.mock.calls.length).toBe(3)
expect(chat.game.mock.calls[0][0]).toBe('room')
expect(chat.game.mock.calls[0][1]).toBe('Player name2 has called (10)')
expect(chat.game.mock.calls[1][0]).toBe('room')
expect(chat.game.mock.calls[1][1]).toBe('The pool prize is 25')
expect(chat.toSelfInTopic.mock.calls.length).toBe(1)
expect(chat.toSelfInTopic.mock.calls[0][0]).toBe('id2')
expect(chat.toSelfInTopic.mock.calls[0][1]).toEqual({ money: 33, id: 'id2' })
expect(chat.toSelfInTopic.mock.calls[0][2]).toBe('update-money-left')
expect(chat.toRoomInTopic.mock.calls.length).toBe(1)
expect(chat.toRoomInTopic.mock.calls[0][0]).toBe('room')
expect(chat.toRoomInTopic.mock.calls[0][1]).toEqual({ poolPrize: 25 })
expect(chat.toRoomInTopic.mock.calls[0][2]).toBe('update-pool-prize')
})