1 package net.pterodactylus.sone.web.ajax
3 import org.hamcrest.MatcherAssert.assertThat
4 import org.hamcrest.Matchers.equalTo
6 import org.mockito.Mockito.verify
9 * Unit test for [UnlikeAjaxPage].
11 class UnlikeAjaxPageTest : JsonPageTest("unlike.ajax", pageSupplier = ::UnlikeAjaxPage) {
14 fun `request without type results in error`() {
15 assertThat(json.isSuccess, equalTo(false))
19 fun `request for post without id results in invalid-post-id`() {
20 addRequestParameter("type", "post")
21 assertThatJsonFailed("invalid-post-id")
25 fun `request for invalid type results in invalid-type`() {
26 addRequestParameter("type", "invalid")
27 addRequestParameter("invalid", "invalid")
28 assertThatJsonFailed("invalid-type")
32 fun `request for post with id removes id from liked posts`() {
33 addRequestParameter("type", "post")
34 addRequestParameter("post", "post-id")
35 assertThatJsonIsSuccessful()
36 verify(currentSone).removeLikedPostId("post-id")
37 verify(core).touchConfiguration()
41 fun `request for reply without id results in invalid-reply-id`() {
42 addRequestParameter("type", "reply")
43 assertThatJsonFailed("invalid-reply-id")
47 fun `request for reply with id removes id from liked replys`() {
48 addRequestParameter("type", "reply")
49 addRequestParameter("reply", "reply-id")
50 assertThatJsonIsSuccessful()
51 verify(currentSone).removeLikedReplyId("reply-id")
52 verify(core).touchConfiguration()