roomList.test.ts
885 Bytes
import { expect } from "chai";
import { RoomManager } from "../room/RoomManager";
import { DummySocket } from "./util/DummySocket";
import { prepareUsersEmptyRooms } from "./util/prepare";
import { SocketTester } from "./util/SocketTester";
describe("방 목록 요청", () => {
const roomManager = new RoomManager();
it("로그인하지 않은 유저는 요청할 수 없습니다.", () => {
const socket = new SocketTester(roomManager);
socket.testNotOk("roomList", {});
});
it("방 목록을 가져옵니다.", () => {
const {
sockets: [socket],
rooms: [room1, room2],
} = prepareUsersEmptyRooms(1, 2);
const response = socket.test("roomList", {});
expect(response.ok).eq(true);
expect(response.result?.length).eq(2);
expect(response.result[0].name).eq(room1.name);
expect(response.result[1].name).eq(room2.name);
});
});