mirror of https://github.com/usbharu/Hideout.git
test: postのテストを追加
This commit is contained in:
parent
c84517908e
commit
6739bb0da2
|
@ -8,6 +8,7 @@ import org.junit.jupiter.api.assertThrows
|
|||
import utils.AssertDomainEvent.assertContainsEvent
|
||||
import utils.AssertDomainEvent.assertEmpty
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
class PostTest {
|
||||
@Test
|
||||
|
@ -210,5 +211,50 @@ class PostTest {
|
|||
assertContainsEvent(post, PostEvent.update.eventName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hideがtrueの時nullを返す() {
|
||||
val post = TestPostFactory.create(hide = true, overview = "aaaa")
|
||||
|
||||
assertNull(post.overview)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hideがfalseの時overviewを返す() {
|
||||
val post = TestPostFactory.create(hide = false, overview = "aaaa")
|
||||
|
||||
assertEquals(PostOverview("aaaa"), post.overview)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deletedがtrueのときセットできない() {
|
||||
val post = TestPostFactory.create(deleted = true)
|
||||
|
||||
assertThrows<IllegalArgumentException> {
|
||||
post.overview = PostOverview("aaaa")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deletedがfalseのときセットできる() {
|
||||
val post = TestPostFactory.create(deleted = false)
|
||||
|
||||
val overview = PostOverview("aaaa")
|
||||
assertDoesNotThrow {
|
||||
post.overview = overview
|
||||
}
|
||||
assertEquals(overview, post.overview)
|
||||
|
||||
assertContainsEvent(post, PostEvent.update.eventName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun overviewの内容が更新されなかった時イベントが発生しない() {
|
||||
val post = TestPostFactory.create(overview = "aaaa")
|
||||
post.overview = PostOverview("aaaa")
|
||||
assertEmpty(post)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue