X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnlikeAjaxPageTest.kt;h=488aacde3d33fe2e1d650fa1f77485ccb946e11d;hb=f7b783ac48b77d0f2b258e3efa7e853388165247;hp=ada19babe2b1caee0c582d71082e9add6475a855;hpb=eec3fc36611c32dd7a0f24be39239868befd2aeb;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt index ada19ba..488aacd 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt @@ -1,7 +1,10 @@ package net.pterodactylus.sone.web.ajax +import net.pterodactylus.sone.test.getInstance +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.Mockito.verify @@ -18,23 +21,21 @@ class UnlikeAjaxPageTest : JsonPageTest("unlike.ajax", pageSupplier = ::UnlikeAj @Test fun `request for post without id results in invalid-post-id`() { addRequestParameter("type", "post") - assertThat(json.isSuccess, equalTo(false)) - assertThat(json.error, equalTo("invalid-post-id")) + assertThatJsonFailed("invalid-post-id") } @Test fun `request for invalid type results in invalid-type`() { addRequestParameter("type", "invalid") addRequestParameter("invalid", "invalid") - assertThat(json.isSuccess, equalTo(false)) - assertThat(json.error, equalTo("invalid-type")) + assertThatJsonFailed("invalid-type") } @Test fun `request for post with id removes id from liked posts`() { addRequestParameter("type", "post") addRequestParameter("post", "post-id") - assertThat(json.isSuccess, equalTo(true)) + assertThatJsonIsSuccessful() verify(currentSone).removeLikedPostId("post-id") verify(core).touchConfiguration() } @@ -42,17 +43,21 @@ class UnlikeAjaxPageTest : JsonPageTest("unlike.ajax", pageSupplier = ::UnlikeAj @Test fun `request for reply without id results in invalid-reply-id`() { addRequestParameter("type", "reply") - assertThat(json.isSuccess, equalTo(false)) - assertThat(json.error, equalTo("invalid-reply-id")) + assertThatJsonFailed("invalid-reply-id") } @Test fun `request for reply with id removes id from liked replys`() { addRequestParameter("type", "reply") addRequestParameter("reply", "reply-id") - assertThat(json.isSuccess, equalTo(true)) + assertThatJsonIsSuccessful() verify(currentSone).removeLikedReplyId("reply-id") verify(core).touchConfiguration() } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }