X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FIndexPageTest.kt;h=8c863650bdf9e160c8ad4de9b2298383b6803673;hp=07eb64a810f1a7a84af09056b086208d1741c9af;hb=HEAD;hpb=125dab18d4412f547334f4fa2b27e5f7676eec5c 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 07eb64a..8c86365 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() @@ -30,18 +24,18 @@ class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, @Test fun `page returns correct path`() { - assertThat(page.path, equalTo("index.html")) + assertThat(page.path, equalTo("index.html")) } @Test fun `page requires login`() { - assertThat(page.requiresLogin(), equalTo(true)) + assertThat(page.requiresLogin(), equalTo(true)) } @Test fun `page returns correct title`() { - whenever(l10n.getString("Page.Index.Title")).thenReturn("index page title") - assertThat(page.getPageTitle(soneRequest), equalTo("index page title")) + addTranslation("Page.Index.Title", "index page title") + assertThat(page.getPageTitle(soneRequest), equalTo("index page title")) } @Before @@ -156,12 +150,17 @@ class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, @Test fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance(), notNullValue()) + assertThat(baseInjector.getInstance(), notNullValue()) } @Test fun `page is annotated with correct menuname`() { - assertThat(page.menuName, equalTo("Index")) + assertThat(page.menuName, equalTo("Index")) + } + + @Test + fun `page is annotated with correct template path`() { + assertThat(page.templatePath, equalTo("/templates/index.html")) } }