1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.test.mock
4 import org.hamcrest.MatcherAssert.assertThat
5 import org.hamcrest.Matchers.equalTo
7 import org.mockito.Mockito.verify
10 * Unit test for [UnfollowSoneAjaxPage].
12 class UnfollowSoneAjaxPageTest : JsonPageTest("unfollowSone.ajax", pageSupplier = ::UnfollowSoneAjaxPage) {
15 fun `request without sone returns invalid-sone-id`() {
16 assertThat(json.isSuccess, equalTo(false))
17 assertThat(json.error, equalTo("invalid-sone-id"))
21 fun `request with invalid sone returns invalid-sone-id`() {
22 addRequestParameter("sone", "invalid")
23 assertThat(json.isSuccess, equalTo(false))
24 assertThat(json.error, equalTo("invalid-sone-id"))
28 fun `request with valid sone unfollows sone`() {
29 addSone(mock(), "sone-id")
30 addRequestParameter("sone", "sone-id")
31 assertThat(json.isSuccess, equalTo(true))
32 verify(core).unfollowSone(currentSone, "sone-id")