setBrush.test.ts
1.77 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
import { expect } from "chai";
import { clear } from "./util/clear";
import { prepareGame } from "./util/prepare";
describe("라운드 브러시 설정", () => {
it("drawer가 브러시를 설정하면 다른 사람들이 설정을 받습니다", () => {
const { drawerSocket, guesserSockets, room } = prepareGame(2);
const brushSettings = {
size: 1,
color: "000000",
drawing: true,
};
drawerSocket.testOk("setBrush", brushSettings);
expect(guesserSockets[0].socket.received("setBrush")).deep.eq(
brushSettings
);
clear([room]);
});
it("올바르지 않은 브러시 색상은 허용되지 않습니다", () => {
const { drawerSocket, room } = prepareGame(2);
drawerSocket.testNotOk("setBrush", {
size: 1,
color: "000",
drawing: true,
});
drawerSocket.testNotOk("setBrush", {
size: 1,
color: "asdf01",
drawing: true,
});
clear([room]);
});
it("올바르지 않은 브러시 사이즈는 Clamp 됩니다", () => {
const { drawerSocket, guesserSockets, room } = prepareGame(2);
drawerSocket.testOk("setBrush", {
size: 0,
color: "000000",
drawing: true,
});
expect(guesserSockets[0].socket.received("setBrush").size).eq(1);
drawerSocket.testOk("setBrush", {
size: 100,
color: "000000",
drawing: true,
});
expect(guesserSockets[0].socket.received("setBrush").size).eq(64);
clear([room]);
});
it("drawer가 아닌 다른 사람들은 브러시를 설정할 수 없습니다", () => {
const { guesserSockets, room } = prepareGame(2);
const brushSettings = {
size: 1,
color: "000000",
drawing: true,
};
guesserSockets[0].testNotOk("setBrush", brushSettings);
clear([room]);
});
});