roomList.test.ts 978 Bytes
import { expect } from "chai";
import { RoomManager } from "../room/RoomManager";
import { DummySocket } from "./util/DummySocket";
import { SocketTester } from "./util/SocketTester";

describe("방 목록 요청", () => {
  const roomManager = new RoomManager();
  it("로그인하지 않은 유저는 요청할 수 없습니다.", () => {
    const socket = new SocketTester(roomManager);
    const response = socket.test("roomList", {});
    expect(response.ok).eq(false);
  });
  it("방 목록을 가져옵니다.", () => {
    const roomManager = new RoomManager();
    roomManager.create("테스트1", 4);
    roomManager.create("테스트2", 2);

    const socket = new SocketTester(roomManager);
    socket.login("guest");

    const response = socket.test("roomList", {});
    expect(response.ok).eq(true);
    expect(response.result?.length).eq(2);
    expect(response.result[0].name).eq("테스트1");
    expect(response.result[1].name).eq("테스트2");
  });
});