Add test for DI constructability of UnlockSonePage
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / pages / UnlockSonePageTest.kt
index 70756e1..1c1ca7f 100644 (file)
@@ -1,9 +1,14 @@
 package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.test.getInstance
 import net.pterodactylus.sone.test.mock
 import net.pterodactylus.sone.test.whenever
+import net.pterodactylus.sone.web.baseInjector
 import net.pterodactylus.util.web.Method.POST
+import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.equalTo
+import org.hamcrest.Matchers.notNullValue
 import org.junit.Test
 import org.mockito.ArgumentMatchers.any
 import org.mockito.Mockito.never
@@ -12,11 +17,23 @@ import org.mockito.Mockito.verify
 /**
  * Unit test for [UnlockSonePage].
  */
-class UnlockSonePageTest : WebPageTest() {
+class UnlockSonePageTest: WebPageTest(::UnlockSonePage) {
 
-       private val page = UnlockSonePage(template, webInterface)
+       @Test
+       fun `page returns correct path`() {
+           assertThat(page.path, equalTo("unlockSone.html"))
+       }
+
+       @Test
+       fun `page does not require login`() {
+           assertThat(page.requiresLogin(), equalTo(false))
+       }
 
-       override fun getPage() = page
+       @Test
+       fun `page returns correct title`() {
+               addTranslation("Page.UnlockSone.Title", "unlock page title")
+           assertThat(page.getPageTitle(freenetRequest), equalTo("unlock page title"))
+       }
 
        @Test
        fun `post request without sone redirects to return page`() {
@@ -60,4 +77,9 @@ class UnlockSonePageTest : WebPageTest() {
                }
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<UnlockSonePage>(), notNullValue())
+       }
+
 }