Add more tests for index page
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 3 May 2017 18:27:05 +0000 (20:27 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 5 May 2017 20:51:35 +0000 (22:51 +0200)
src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt

index e6256bb..978e8ed 100644 (file)
@@ -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<PostVisibilityFilter>()
        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<Post> { true })