From: David ‘Bombe’ Roden Date: Sat, 21 Jan 2017 15:03:46 +0000 (+0100) Subject: Add unit test for unfollow sone page X-Git-Tag: 0.9.7^2~326 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9f1c3804c4299e033b4e34ef659a155934803b1a;p=Sone.git Add unit test for unfollow sone page --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/UnfollowSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/UnfollowSonePageTest.kt new file mode 100644 index 0000000..b9c3433 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/web/UnfollowSonePageTest.kt @@ -0,0 +1,42 @@ +package net.pterodactylus.sone.web + +import net.pterodactylus.util.web.Method.POST +import org.junit.Test +import org.mockito.Mockito.verify + +/** + * Unit test for [UnfollowSonePage]. + */ +class UnfollowSonePageTest : WebPageTest() { + + private val page = UnfollowSonePage(template, webInterface) + + override fun getPage() = page + + @Test + fun `get request does not redirect`() { + page.handleRequest(freenetRequest, templateContext) + } + + @Test + fun `post request unfollows a single sone and redirects to return page`() { + request("", POST) + addHttpRequestParameter("returnPage", "return.html") + addHttpRequestParameter("sone", "sone-id") + verifyRedirect("return.html") { + verify(core).unfollowSone(currentSone, "sone-id") + } + } + + @Test + fun `post request unfollows two sones and redirects to return page`() { + request("", POST) + addHttpRequestParameter("returnPage", "return.html") + addHttpRequestParameter("sone", "sone-id1, sone-id2") + verifyRedirect("return.html") { + verify(core).unfollowSone(currentSone, "sone-id1") + verify(core).unfollowSone(currentSone, "sone-id2") + } + } + +}