From: David ‘Bombe’ Roden Date: Wed, 3 May 2017 18:27:05 +0000 (+0200) Subject: Add more tests for index page X-Git-Tag: 0.9.7^2~226 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a1632b81704f2be457469b4ade584a6ad31c7bec;p=Sone.git Add more tests for index page --- 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 e6256bb..978e8ed 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt @@ -12,6 +12,7 @@ import net.pterodactylus.sone.web.pages.WebPageTest import net.pterodactylus.util.web.Method.GET import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains +import org.hamcrest.Matchers.equalTo import org.junit.Before import org.junit.Test import org.mockito.ArgumentMatchers @@ -24,6 +25,22 @@ class IndexPageTest : WebPageTest() { private val postVisibilityFilter = mock() private val page = IndexPage(template, webInterface, postVisibilityFilter) + @Test + fun `page returns correct path`() { + assertThat(page.path, equalTo("index.html")) + } + + @Test + fun `page requires login`() { + assertThat(page.requiresLogin(), equalTo(true)) + } + + @Test + fun `page returns correct title`() { + whenever(l10n.getString("Page.Index.Title")).thenReturn("index page title") + assertThat(page.getPageTitle(freenetRequest), equalTo("index page title")) + } + @Before fun setupPostVisibilityFilter() { whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn(Predicate { true })