X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FIndexPageTest.kt;h=ba0f216987643c81e94734c1886c998f8fe17638;hb=a76956e389fcfe6282ad4ca7156bbf76327bb0c0;hp=b5dc447b6a9febc46cd412f8d73dc49a51567e93;hpb=2a5f8e05524b1884161ea5efdba1d5cfce4df160;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt index b5dc447..ba0f216 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt @@ -1,28 +1,22 @@ package net.pterodactylus.sone.web.pages -import com.google.common.base.Optional.fromNullable -import com.google.common.base.Predicate -import net.pterodactylus.sone.data.Post -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.notify.PostVisibilityFilter -import net.pterodactylus.sone.test.getInstance -import net.pterodactylus.sone.test.mock -import net.pterodactylus.sone.test.whenever -import net.pterodactylus.sone.utils.Pagination -import net.pterodactylus.sone.web.baseInjector -import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.contains -import org.hamcrest.Matchers.emptyIterable -import org.hamcrest.Matchers.equalTo -import org.hamcrest.Matchers.notNullValue -import org.junit.Before -import org.junit.Test -import org.mockito.ArgumentMatchers +import com.google.common.base.* +import com.google.common.base.Optional.* +import net.pterodactylus.sone.data.* +import net.pterodactylus.sone.notify.* +import net.pterodactylus.sone.test.* +import net.pterodactylus.sone.utils.* +import net.pterodactylus.sone.web.* +import net.pterodactylus.sone.web.page.* +import org.hamcrest.MatcherAssert.* +import org.hamcrest.Matchers.* +import org.junit.* +import org.mockito.* /** * Unit test for [IndexPage]. */ -class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, webInterface, postVisibilityFilter) }) { +class IndexPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> IndexPage(webInterface, loaders, templateRenderer, postVisibilityFilter) }) { companion object { private val postVisibilityFilter = mock() @@ -41,7 +35,7 @@ class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, @Test fun `page returns correct title`() { whenever(l10n.getString("Page.Index.Title")).thenReturn("index page title") - assertThat(page.getPageTitle(freenetRequest), equalTo("index page title")) + assertThat(page.getPageTitle(soneRequest), equalTo("index page title")) } @Before @@ -137,7 +131,7 @@ class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, fun `index page sets page correctly`() { val posts = listOf(createPost(3000), createPost(2000), createPost(1000)) whenever(currentSone.posts).thenReturn(posts) - core.preferences.postsPerPage = 1 + core.preferences.newPostsPerPage = 1 addHttpRequestParameter("page", "2") page.processTemplate(freenetRequest, templateContext) @Suppress("UNCHECKED_CAST") @@ -146,7 +140,7 @@ class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, @Test fun `index page without posts sets correct pagination`() { - core.preferences.postsPerPage = 1 + core.preferences.newPostsPerPage = 1 page.processTemplate(freenetRequest, templateContext) @Suppress("UNCHECKED_CAST") (templateContext["pagination"] as Pagination).let { pagination -> @@ -159,4 +153,14 @@ class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, assertThat(baseInjector.getInstance(), notNullValue()) } + @Test + fun `page is annotated with correct menuname`() { + assertThat(page.menuName, equalTo("Index")) + } + + @Test + fun `page is annotated with correct template path`() { + assertThat(page.templatePath, equalTo("/templates/index.html")) + } + }