chooseWord.test.ts
1.53 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
import { expect } from "chai";
import { clear } from "./util/clear";
import { prepareGame } from "./util/prepare";
describe("라운드 단어 선택", () => {
it("drawer가 단어를 선택하면 wordChosen과 timer를 받습니다", () => {
const { drawerSocket, guesserSockets, room } = prepareGame(2);
const word = drawerSocket.socket.received("wordSet").words[0];
drawerSocket.testOk("chooseWord", { word });
expect(drawerSocket.socket.received("wordChosen").length).eq(word.length);
drawerSocket.socket.received("timer");
expect(guesserSockets[0].socket.received("wordChosen").length).eq(
word.length
);
guesserSockets[0].socket.received("timer");
clear([room]);
});
it("drawer가 아닌 다른 사람들은 단어를 선택할 수 없습니다", () => {
const { drawerSocket, guesserSockets, room } = prepareGame(2);
const word = drawerSocket.socket.received("wordSet").words[0];
guesserSockets[0].testNotOk("chooseWord", { word });
clear([room]);
});
it("단어를 이미 고른 상태에서 다시 고를 수 없습니다", () => {
const { drawerSocket, room } = prepareGame(2);
const word = drawerSocket.socket.received("wordSet").words[0];
drawerSocket.testOk("chooseWord", { word });
drawerSocket.testNotOk("chooseWord", { word });
clear([room]);
});
it("목록에 없는 단어를 고를 수 없습니다", () => {
const { drawerSocket, room } = prepareGame(2);
drawerSocket.testNotOk("chooseWord", { word: "Nope!" });
clear([room]);
});
});