Replace known Sones page with Kotlin version
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / pages / UnfollowSonePageTest.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.web.pages.UnfollowSonePage
4 import net.pterodactylus.util.web.Method.POST
5 import org.junit.Test
6 import org.mockito.Mockito.verify
7
8 /**
9  * Unit test for [UnfollowSonePage].
10  */
11 class UnfollowSonePageTest : WebPageTest() {
12
13         private val page = UnfollowSonePage(template, webInterface)
14
15         override fun getPage() = page
16
17         @Test
18         fun `get request does not redirect`() {
19                 page.handleRequest(freenetRequest, templateContext)
20         }
21
22         @Test
23         fun `post request unfollows a single sone and redirects to return page`() {
24                 request("", POST)
25                 addHttpRequestPart("returnPage", "return.html")
26                 addHttpRequestPart("sone", "sone-id")
27                 verifyRedirect("return.html") {
28                         verify(core).unfollowSone(currentSone, "sone-id")
29                 }
30         }
31
32         @Test
33         fun `post request unfollows two sones and redirects to return page`() {
34                 request("", POST)
35                 addHttpRequestPart("returnPage", "return.html")
36                 addHttpRequestPart("sone", "sone-id1, sone-id2")
37                 verifyRedirect("return.html") {
38                         verify(core).unfollowSone(currentSone, "sone-id1")
39                         verify(core).unfollowSone(currentSone, "sone-id2")
40                 }
41         }
42
43 }