startGame.test.ts
1.08 KB
import { expect } from "chai";
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", {}));
});
it("인원이 충분해야 게임을 시작할 수 있습니다.", () => {
const {
sockets: [socket1],
} = prepareJoinedRoom(1);
expect(socket1.testNotOk("startGame", {}));
});
it("게임이 시작되면 startRound를 받습니다.", () => {
const {
sockets: [socket1, socket2],
} = prepareJoinedRoom(2);
expect(socket2.testOk("ready", { ready: true }));
expect(socket1.testOk("startGame", {}));
expect(socket1.socket.received("startRound"));
expect(socket2.socket.received("startRound"));
});
});