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=22cba9f9a8bdae7284bfb0bbc627304c60777c44;hp=5b3c959851264821c9a97e7db1705d664ceff664;hb=369ba7692f167e5b7f9a27898a06a5d7920904ed;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..22cba9f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt @@ -4,43 +4,44 @@ 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 +import java.net.* /** * 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()) - private val foreignPost2 = createPost("foreign-post2", "Second Foreign Post.", 2000, mock()) - private val foreignPost3 = createPost("foreign-post3", "Third Foreign Post.", 3000, mock()) - 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 + private val foreignPost1 = createPost("foreign-post1", "First Foreign Post.", 1000, mock()) + private val foreignPost2 = createPost("foreign-post2", "Second Foreign Post.", 2000, mock()) + private val foreignPost3 = createPost("foreign-post3", "Third Foreign Post.", 3000, mock()) + private val directed1 = createPost("post3", "First directed.", 1500, mock(), recipient = currentSone) + private val directed2 = createPost("post4", "Second directed.", 2500, mock(), recipient = currentSone) @Before fun setup() { whenever(currentSone.posts).thenReturn(mutableListOf(post2, post1)) whenever(core.getDirectedPosts("sone-id")).thenReturn(setOf(directed1, directed2)) - core.preferences.postsPerPage = 2 + core.preferences.newPostsPerPage = 2 } @Test @@ -204,7 +205,12 @@ class ViewSonePageTest: WebPageTest() { @Test fun `page is link-excepted`() { - assertThat(page.isLinkExcepted(null), equalTo(true)) + assertThat(page.isLinkExcepted(URI("")), equalTo(true)) + } + + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) } }