Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
강동현
2021-06-09 21:55:04 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
859a233d530cfbb64c7b39319253d2c0aee5be25
859a233d
1 parent
72359b5c
createRoom 테스트 작성
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
server/test/createRoom.test.ts
server/test/createRoom.test.ts
0 → 100644
View file @
859a233
import
{
expect
}
from
"chai"
;
import
{
RoomManager
}
from
"../room/RoomManager"
;
import
{
prepareJoinedRoom
,
prepareUsers
,
prepareUsersEmptyRooms
,
}
from
"./util/prepare"
;
import
{
SocketTester
}
from
"./util/SocketTester"
;
describe
(
"방 생성"
,
()
=>
{
it
(
"로그인하지 않은 유저는 요청할 수 없습니다"
,
()
=>
{
const
roomManager
=
new
RoomManager
();
const
socket
=
new
SocketTester
(
roomManager
);
socket
.
testNotOk
(
"createRoom"
,
{
name
:
"테스트"
});
});
it
(
"방을 생성합니다"
,
()
=>
{
const
{
sockets
:
[
socket
],
users
:
[
user
],
}
=
prepareUsers
(
1
);
const
response
=
socket
.
test
(
"createRoom"
,
{
name
:
"테스트"
});
expect
(
response
.
ok
).
eq
(
true
);
expect
(
response
.
result
?.
name
).
eq
(
"테스트"
);
expect
(
response
.
result
?.
users
?.
length
).
eq
(
1
);
expect
(
response
.
result
?.
users
[
0
]?.
username
).
eq
(
user
.
username
);
});
it
(
"방을 생성하면 방장이 됩니다"
,
()
=>
{
const
{
sockets
:
[
socket
],
}
=
prepareUsers
(
1
);
const
response
=
socket
.
test
(
"createRoom"
,
{
name
:
"테스트"
});
expect
(
response
.
ok
).
eq
(
true
);
expect
(
response
.
result
?.
users
[
0
]?.
admin
).
eq
(
true
);
});
it
(
"방의 이름은 공백이 될 수 없습니다"
,
()
=>
{
const
{
sockets
:
[
socket
],
}
=
prepareUsers
(
1
);
socket
.
testNotOk
(
"createRoom"
,
{
name
:
""
});
socket
.
testNotOk
(
"createRoom"
,
{
name
:
" "
});
});
it
(
"방의 이름은 30자보다 길 수 없습니다"
,
()
=>
{
const
{
sockets
:
[
socket
],
}
=
prepareUsers
(
1
);
socket
.
testNotOk
(
"createRoom"
,
{
name
:
"a"
.
repeat
(
31
)
});
socket
.
testNotOk
(
"createRoom"
,
{
name
:
"가"
.
repeat
(
31
)
});
});
it
(
"방에 이미 접속한 상태에서 방을 만들 수 없습니다"
,
()
=>
{
const
{
sockets
:
[
socket
],
}
=
prepareJoinedRoom
(
1
);
socket
.
testNotOk
(
"createRoom"
,
{
name
:
"테스트"
});
});
});
Please
register
or
login
to post a comment