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
8 import org.mockito.Mockito.verifyNoMoreInteractions
11 * Unit test for [LikePage].
13 class LikePageTest: WebPageTest(::LikePage) {
16 fun `page returns correct path`() {
17 assertThat(page.path, equalTo("like.html"))
21 fun `page requires login`() {
22 assertThat(page.requiresLogin(), equalTo(true))
26 fun `page returns correct title`() {
27 addTranslation("Page.Like.Title", "like page title")
28 assertThat(page.getPageTitle(freenetRequest), equalTo("like page title"))
32 fun `get request does not redirect`() {
37 fun `post request with post id likes post and redirects to return page`() {
39 addHttpRequestPart("type", "post")
40 addHttpRequestPart("post", "post-id")
41 addHttpRequestPart("returnPage", "return.html")
42 verifyRedirect("return.html") {
43 verify(currentSone).addLikedPostId("post-id")
48 fun `post request with reply id likes post and redirects to return page`() {
50 addHttpRequestPart("type", "reply")
51 addHttpRequestPart("reply", "reply-id")
52 addHttpRequestPart("returnPage", "return.html")
53 verifyRedirect("return.html") {
54 verify(currentSone).addLikedReplyId("reply-id")
59 fun `post request with invalid likes redirects to return page`() {
61 addHttpRequestPart("type", "foo")
62 addHttpRequestPart("returnPage", "return.html")
63 verifyRedirect("return.html") {
64 verifyNoMoreInteractions(currentSone)