1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.test.getInstance
4 import net.pterodactylus.sone.web.baseInjector
5 import net.pterodactylus.util.web.Method.POST
6 import org.hamcrest.MatcherAssert.assertThat
7 import org.hamcrest.Matchers.equalTo
8 import org.hamcrest.Matchers.notNullValue
10 import org.mockito.Mockito.verify
13 * Unit test for [UnfollowSonePage].
15 class UnfollowSonePageTest: WebPageTest(::UnfollowSonePage) {
18 fun `page returns correct path`() {
19 assertThat(page.path, equalTo("unfollowSone.html"))
23 fun `page requires login`() {
24 assertThat(page.requiresLogin(), equalTo(true))
28 fun `page returns correct page title`() {
29 addTranslation("Page.UnfollowSone.Title", "unfollow page title")
30 assertThat(page.getPageTitle(freenetRequest), equalTo("unfollow page title"))
34 fun `get request does not redirect`() {
39 fun `post request unfollows a single sone and redirects to return page`() {
41 addHttpRequestPart("returnPage", "return.html")
42 addHttpRequestPart("sone", "sone-id")
43 verifyRedirect("return.html") {
44 verify(core).unfollowSone(currentSone, "sone-id")
49 fun `post request unfollows two sones and redirects to return page`() {
51 addHttpRequestPart("returnPage", "return.html")
52 addHttpRequestPart("sone", "sone-id1, sone-id2")
53 verifyRedirect("return.html") {
54 verify(core).unfollowSone(currentSone, "sone-id1")
55 verify(core).unfollowSone(currentSone, "sone-id2")
60 fun `page can be created by dependency injection`() {
61 assertThat(baseInjector.getInstance<UnfollowSonePage>(), notNullValue())