1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.util.web.Method.POST
4 import org.hamcrest.MatcherAssert.assertThat
5 import org.hamcrest.Matchers.equalTo
7 import org.mockito.Mockito.verify
10 * Unit test for [UnfollowSonePage].
12 class UnfollowSonePageTest: WebPageTest2(::UnfollowSonePage) {
15 fun `page returns correct path`() {
16 assertThat(page.path, equalTo("unfollowSone.html"))
20 fun `page requires login`() {
21 assertThat(page.requiresLogin(), equalTo(true))
25 fun `page returns correct page title`() {
26 addTranslation("Page.UnfollowSone.Title", "unfollow page title")
27 assertThat(page.getPageTitle(freenetRequest), equalTo("unfollow page title"))
31 fun `get request does not redirect`() {
36 fun `post request unfollows a single sone and redirects to return page`() {
38 addHttpRequestPart("returnPage", "return.html")
39 addHttpRequestPart("sone", "sone-id")
40 verifyRedirect("return.html") {
41 verify(core).unfollowSone(currentSone, "sone-id")
46 fun `post request unfollows two sones and redirects to return page`() {
48 addHttpRequestPart("returnPage", "return.html")
49 addHttpRequestPart("sone", "sone-id1, sone-id2")
50 verifyRedirect("return.html") {
51 verify(core).unfollowSone(currentSone, "sone-id1")
52 verify(core).unfollowSone(currentSone, "sone-id2")