-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnextState.test.js
More file actions
33 lines (28 loc) · 1017 Bytes
/
nextState.test.js
File metadata and controls
33 lines (28 loc) · 1017 Bytes
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
const NextState = require('./nextState')
function Chat() {
return {
// eslint-disable-next-line no-unused-vars
game: jest.fn((roomName, message) => {}),
// eslint-disable-next-line no-unused-vars
toRoomInTopic: jest.fn((room, message, topic) => {}),
}
}
function NextStateMock() {
return {
// eslint-disable-next-line no-unused-vars
print: jest.fn((chat) => {}),
}
}
test("I can bet on the game, if it's my turn", () => {
const chat = Chat()
const nextStateMock = NextStateMock()
const nextState = NextState(['9h'], 'room', nextStateMock)
nextState.print(chat)
expect(chat.game.mock.calls.length).toBe(1)
expect(chat.game.mock.calls[0][0]).toBe('room')
expect(chat.game.mock.calls[0][1]).toBe('Common cards are 9♥️')
expect(chat.toRoomInTopic.mock.calls.length)
expect(chat.toRoomInTopic.mock.calls[0][0]).toBe('room')
expect(chat.toRoomInTopic.mock.calls[0][1]).toBe('9♥️')
expect(chat.toRoomInTopic.mock.calls[0][2]).toBe('update-common-cards')
})