96 lines
2.8 KiB
Kotlin

package roomescape.view.controller
import org.hamcrest.Matchers.containsString
import roomescape.common.RoomescapeApiTest
class PageControllerTest() : RoomescapeApiTest() {
init {
listOf("/", "/login").forEach {
given("GET $it 요청은") {
`when`("로그인 및 권한 여부와 관계없이 성공한다.") {
then("비회원") {
setUpNotLoggedIn()
runGetTest(it) {
statusCode(200)
}
}
then("회원") {
setUpUser()
runGetTest(it) {
statusCode(200)
}
}
then("관리자") {
setUpAdmin()
runGetTest(it) {
statusCode(200)
}
}
}
}
}
listOf("/admin", "/admin/reservation", "/admin/time", "/admin/theme", "/admin/waiting").forEach {
given("GET $it 요청을") {
`when`("관리자가 보내면") {
setUpAdmin()
then("성공한다.") {
runGetTest(it) {
statusCode(200)
}
}
}
`when`("회원이 보내면") {
setUpUser()
then("로그인 페이지로 이동한다.") {
runGetTest(it) {
statusCode(200)
body(containsString("<title>Login</title>"))
}
}
}
}
}
listOf("/reservation", "/reservation-mine").forEach {
given("GET $it 요청을") {
`when`("로그인 된 회원이 보내면 성공한다.") {
then("회원") {
setUpUser()
runGetTest(it) {
statusCode(200)
}
}
then("관리자") {
setUpAdmin()
runGetTest(it) {
statusCode(200)
}
}
}
`when`("로그인 없이 보내면") {
then("로그인 페이지로 이동한다.") {
setUpNotLoggedIn()
runGetTest(it) {
statusCode(200)
body(containsString("<title>Login</title>"))
}
}
}
}
}
}
}