Skip to content

Commit

Permalink
test: add test codes for VerifyContactEmailUseCase
Browse files Browse the repository at this point in the history
  • Loading branch information
chock-cho committed Feb 4, 2025
1 parent 4c200de commit 5877588
Showing 1 changed file with 41 additions and 0 deletions.
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)
}
}
}
}
})

0 comments on commit 5877588

Please sign in to comment.