✨ Use @TemplatePath annotations on most pages
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / pages / DeleteAlbumPageTest.kt
index c618400..28f7880 100644 (file)
@@ -2,11 +2,15 @@ package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.data.Album
 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.sone.web.page.*
 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.Before
 import org.junit.Test
 import org.mockito.ArgumentMatchers.anyString
@@ -15,16 +19,12 @@ import org.mockito.Mockito.verify
 /**
  * Unit test for [DeleteAlbumPage].
  */
-class DeleteAlbumPageTest: WebPageTest() {
-
-       private val page = DeleteAlbumPage(template, webInterface)
+class DeleteAlbumPageTest: WebPageTest(::DeleteAlbumPage) {
 
        private val sone = mock<Sone>()
        private val album = mock<Album>()
        private val parentAlbum = mock<Album>()
 
-       override fun getPage() = page
-
        @Before
        fun setupAlbums() {
                whenever(sone.id).thenReturn("sone-id")
@@ -100,7 +100,7 @@ class DeleteAlbumPageTest: WebPageTest() {
        fun `album is deleted and page redirects to album if parent album is not root album`() {
                setMethod(POST)
                whenever(parentAlbum.isRoot).thenReturn(false)
-               whenever(sone.rootAlbum).thenReturn(mock<Album>())
+               whenever(sone.rootAlbum).thenReturn(mock())
                addAlbum("album-id", album)
                addHttpRequestPart("album", "album-id")
                verifyRedirect("imageBrowser.html?album=parent-id") {
@@ -108,4 +108,14 @@ class DeleteAlbumPageTest: WebPageTest() {
                }
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+               assertThat(baseInjector.getInstance<DeleteAlbumPage>(), notNullValue())
+       }
+
+       @Test
+       fun `page is annotated with correct template path`() {
+           assertThat(page.templatePath, equalTo("/templates/deleteAlbum.html"))
+       }
+
 }