1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.test.mock
5 import net.pterodactylus.sone.test.whenever
6 import org.hamcrest.MatcherAssert.assertThat
7 import org.hamcrest.Matchers.equalTo
9 import org.mockito.Mockito.verify
12 * Unit test for [UnfollowSoneAjaxPage].
14 class UnfollowSoneAjaxPageTest : JsonPageTest("unfollowSone.ajax", pageSupplier = ::UnfollowSoneAjaxPage) {
17 fun `request without sone returns invalid-sone-id`() {
18 assertThatJsonFailed("invalid-sone-id")
22 fun `request with invalid sone returns invalid-sone-id`() {
23 addRequestParameter("sone", "invalid")
24 assertThatJsonFailed("invalid-sone-id")
28 fun `request with valid sone unfollows sone`() {
29 addSone(mock<Sone>().apply { whenever(id).thenReturn("sone-id") })
30 addRequestParameter("sone", "sone-id")
31 assertThatJsonIsSuccessful()
32 verify(core).unfollowSone(currentSone, "sone-id")