-
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.
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
app/src/test/kotlin/com/wespot/auth/fixture/KakaoTemplateFixture.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,19 @@ | ||
package com.wespot.auth.fixture | ||
|
||
import com.wespot.auth.KakaoTemplate | ||
import com.wespot.auth.KakaoTemplateType | ||
|
||
object KakaoTemplateFixture { | ||
|
||
fun createKakaoTemplate(): KakaoTemplate { | ||
return KakaoTemplate( | ||
id = 1L, | ||
type = KakaoTemplateType.TELL, | ||
title = "title", | ||
description = "description", | ||
imageUrl = "imageUrl", | ||
buttonText = "buttonText", | ||
url = "url" | ||
) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/test/kotlin/com/wespot/auth/service/KakaoTemplateServiceTest.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,49 @@ | ||
package com.wespot.auth.service | ||
|
||
import com.wespot.auth.KakaoTemplate | ||
import com.wespot.auth.KakaoTemplateType | ||
import com.wespot.auth.dto.response.KakaoTemplateResponse | ||
import com.wespot.auth.fixture.KakaoTemplateFixture.createKakaoTemplate | ||
import com.wespot.auth.port.out.KakaoTemplatePort | ||
import com.wespot.auth.service.kakao.KakaoTemplateService | ||
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 KakaoTemplateServiceTest : BehaviorSpec({ | ||
|
||
val kakaoTemplatePort = mockk<KakaoTemplatePort>() | ||
val kakaoTemplateService = KakaoTemplateService(kakaoTemplatePort) | ||
|
||
given("KakaoTemplateService") { | ||
|
||
`when`("getKakaoTemplate 호출 시 템플릿이 존재하는 경우") { | ||
val type = KakaoTemplateType.TELL | ||
val kakaoTemplate = createKakaoTemplate() | ||
val expectedResponse = KakaoTemplateResponse.from(kakaoTemplate) | ||
|
||
every { kakaoTemplatePort.getKakaoTemplate(type) } returns kakaoTemplate | ||
|
||
val result = kakaoTemplateService.getKakaoTemplate(type) | ||
|
||
then("해당 템플릿을 정상적으로 반환해야 한다") { | ||
result shouldBe expectedResponse | ||
} | ||
} | ||
|
||
`when`("getKakaoTemplate 호출 시 템플릿이 존재하지 않는 경우") { | ||
val type = KakaoTemplateType.FIND | ||
|
||
every { kakaoTemplatePort.getKakaoTemplate(type) } returns null | ||
|
||
then("NoSuchElementException이 발생해야 한다") { | ||
shouldThrow<NoSuchElementException> { | ||
kakaoTemplateService.getKakaoTemplate(type) | ||
}.message shouldBe "해당 타입에는 카카오 템플릿이 존재하지 않습니다." | ||
} | ||
} | ||
} | ||
}) |