X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FViewSonePageTest.kt;h=67adb8f8b8ce04e9cf1314208694d7b6d05a28c2;hp=5b3c959851264821c9a97e7db1705d664ceff664;hb=4526c36c096204837d478ac3a74fd78660eb20f5;hpb=1bd4979e2d3da9d4e9f400f054e6e1d91890669b diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt index 5b3c959..67adb8f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt @@ -4,14 +4,17 @@ import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.PostReply import net.pterodactylus.sone.data.Profile import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.isOnPage import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import net.pterodactylus.sone.utils.Pagination import net.pterodactylus.sone.utils.asOptional +import net.pterodactylus.sone.web.baseInjector import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.hamcrest.Matchers.nullValue import org.junit.Before import org.junit.Test @@ -19,13 +22,12 @@ import org.junit.Test /** * Unit test for [ViewSonePage]. */ -class ViewSonePageTest: WebPageTest() { +class ViewSonePageTest: WebPageTest(::ViewSonePage) { init { whenever(currentSone.id).thenReturn("sone-id") } - private val page = ViewSonePage(template, webInterface) private val post1 = createPost("post1", "First Post.", 1000, currentSone) private val post2 = createPost("post2", "Second Post.", 2000, currentSone) private val foreignPost1 = createPost("foreign-post1", "First Foreign Post.", 1000, mock()) @@ -34,8 +36,6 @@ class ViewSonePageTest: WebPageTest() { private val directed1 = createPost("post3", "First directed.", 1500, mock(), recipient = currentSone) private val directed2 = createPost("post4", "Second directed.", 2500, mock(), recipient = currentSone) - override fun getPage() = page - @Before fun setup() { whenever(currentSone.posts).thenReturn(mutableListOf(post2, post1)) @@ -207,4 +207,9 @@ class ViewSonePageTest: WebPageTest() { assertThat(page.isLinkExcepted(null), equalTo(true)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }