startGame.test.ts
1.2 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
import { expect } from "chai";
import { clear } from "./util/clear";
import { prepareJoinedRoom, prepareUsersEmptyRooms } from "./util/prepare";
describe("게임 시작", () => {
it("방장만 게임 시작을 요청할 수 있습니다.", () => {
const {
sockets: [socket1, socket2],
room,
} = prepareJoinedRoom(2);
expect(room.admin).eq(socket1.connection.user);
expect(socket2.testOk("ready", { ready: true }));
expect(room.canStart().ok).eq(true);
expect(socket2.testNotOk("startGame", {}));
expect(socket1.testOk("startGame", {}));
clear([room]);
});
it("인원이 충분해야 게임을 시작할 수 있습니다.", () => {
const {
sockets: [socket1],
room,
} = prepareJoinedRoom(1);
expect(socket1.testNotOk("startGame", {}));
clear([room]);
});
it("게임이 시작되면 startRound를 받습니다.", () => {
const {
sockets: [socket1, socket2],
room,
} = prepareJoinedRoom(2);
expect(socket2.testOk("ready", { ready: true }));
expect(socket1.testOk("startGame", {}));
expect(socket1.socket.received("startRound"));
expect(socket2.socket.received("startRound"));
clear([room]);
});
});