X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnfollowSoneAjaxPageTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnfollowSoneAjaxPageTest.kt;h=99b7298b90567fbb7840a7823df92337f24c82cc;hp=0000000000000000000000000000000000000000;hb=0906276a29e2b5bc8ebe689ee0bdb52199186cc2;hpb=2cae21104ac3a7a53e2dafc92e0fefddb43fe41f diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPageTest.kt new file mode 100644 index 0000000..99b7298 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPageTest.kt @@ -0,0 +1,35 @@ +package net.pterodactylus.sone.web.ajax + +import net.pterodactylus.sone.test.mock +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.junit.Test +import org.mockito.Mockito.verify + +/** + * Unit test for [UnfollowSoneAjaxPage]. + */ +class UnfollowSoneAjaxPageTest : JsonPageTest("unfollowSone.ajax", pageSupplier = ::UnfollowSoneAjaxPage) { + + @Test + fun `request without sone returns invalid-sone-id`() { + assertThat(json.isSuccess, equalTo(false)) + assertThat(json.error, equalTo("invalid-sone-id")) + } + + @Test + fun `request with invalid sone returns invalid-sone-id`() { + addRequestParameter("sone", "invalid") + assertThat(json.isSuccess, equalTo(false)) + assertThat(json.error, equalTo("invalid-sone-id")) + } + + @Test + fun `request with valid sone unfollows sone`() { + addSone(mock(), "sone-id") + addRequestParameter("sone", "sone-id") + assertThat(json.isSuccess, equalTo(true)) + verify(core).unfollowSone(currentSone, "sone-id") + } + +}