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
@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
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())
+ }
+
}