Add test for DI constructability of UnbookmarkAjaxPage
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / ajax / UnbookmarkAjaxPageTest.kt
index 23ebd9f..b54981f 100644 (file)
@@ -1,9 +1,12 @@
 package net.pterodactylus.sone.web.ajax
 
 import net.pterodactylus.sone.data.Post
+import net.pterodactylus.sone.test.getInstance
 import net.pterodactylus.sone.test.mock
+import net.pterodactylus.sone.web.baseInjector
 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.ArgumentMatchers.eq
@@ -17,15 +20,13 @@ class UnbookmarkAjaxPageTest : JsonPageTest("unbookmark.ajax", requiresLogin = f
 
        @Test
        fun `request without post id results in invalid-post-id`() {
-               assertThat(json.isSuccess, equalTo(false))
-               assertThat(json.error, equalTo("invalid-post-id"))
+               assertThatJsonFailed("invalid-post-id")
        }
 
        @Test
        fun `request with empty post id results in invalid-post-id`() {
                addRequestParameter("post", "")
-               assertThat(json.isSuccess, equalTo(false))
-               assertThat(json.error, equalTo("invalid-post-id"))
+               assertThatJsonFailed("invalid-post-id")
        }
 
        @Test
@@ -40,8 +41,13 @@ class UnbookmarkAjaxPageTest : JsonPageTest("unbookmark.ajax", requiresLogin = f
                val post = mock<Post>()
                addPost(post, "post-id")
                addRequestParameter("post", "post-id")
-               assertThat(json.isSuccess, equalTo(true))
+               assertThatJsonIsSuccessful()
                verify(core).unbookmarkPost(eq(post))
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<UnbookmarkAjaxPage>(), notNullValue())
+       }
+
 }