login.test.ts
1.01 KB
import { expect } from "chai";
import { RoomManager } from "../room/RoomManager";
import { SocketTester } from "./util/SocketTester";
describe("로그인", () => {
it("닉네임으로 로그인합니다", () => {
const roomManager = new RoomManager();
const socket = new SocketTester(roomManager);
const response = socket.test("login", { nickname: "guest" });
expect(response.result !== undefined).eq(true);
expect(socket.connection.user?.nickname).eq("guest");
});
it("빈 닉네임으로 로그인할 수 없습니다", () => {
const roomManager = new RoomManager();
const socket = new SocketTester(roomManager);
socket.testNotOk("login", { nickname: "" });
socket.testNotOk("login", { nickname: " " });
});
it("닉네임은 최대 12자입니다", () => {
const roomManager = new RoomManager();
const socket = new SocketTester(roomManager);
socket.testNotOk("login", { nickname: "a".repeat(13) });
socket.testNotOk("login", { nickname: "가".repeat(13) });
});
});