-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test codes for VerifyContactEmailUseCase
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...test/kotlin/com/dobby/backend/application/usecase/member/VerifyContactEmailUseCaseTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.dobby.backend.application.usecase.member | ||
|
||
import com.dobby.backend.domain.exception.SignupContactEmailDuplicateException | ||
import com.dobby.backend.domain.gateway.member.MemberGateway | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
|
||
class VerifyContactEmailUseCaseTest : BehaviorSpec({ | ||
|
||
val memberGateway = mockk<MemberGateway>() | ||
val verifyContactEmailUseCase = VerifyContactEmailUseCase(memberGateway) | ||
|
||
given("회원 가입 시 이메일 중복 확인") { | ||
|
||
`when`("이메일이 데이터베이스에 존재하지 않는 경우") { | ||
val input = VerifyContactEmailUseCase.Input(contactEmail = "[email protected]") | ||
|
||
every { memberGateway.findByContactEmail(input.contactEmail) } returns null | ||
|
||
then("이메일 사용 가능 응답을 반환해야 한다") { | ||
val result = verifyContactEmailUseCase.execute(input) | ||
result.success shouldBe true | ||
} | ||
} | ||
|
||
`when`("이메일이 이미 존재하는 경우") { | ||
val input = VerifyContactEmailUseCase.Input(contactEmail = "[email protected]") | ||
|
||
every { memberGateway.findByContactEmail(input.contactEmail) } returns mockk() | ||
|
||
then("SignupContactEmailDuplicateException 예외가 발생해야 한다") { | ||
shouldThrow<SignupContactEmailDuplicateException> { | ||
verifyContactEmailUseCase.execute(input) | ||
} | ||
} | ||
} | ||
} | ||
}) |