99b7298b90567fbb7840a7823df92337f24c82cc
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / ajax / UnfollowSoneAjaxPageTest.kt
1 package net.pterodactylus.sone.web.ajax
2
3 import net.pterodactylus.sone.test.mock
4 import org.hamcrest.MatcherAssert.assertThat
5 import org.hamcrest.Matchers.equalTo
6 import org.junit.Test
7 import org.mockito.Mockito.verify
8
9 /**
10  * Unit test for [UnfollowSoneAjaxPage].
11  */
12 class UnfollowSoneAjaxPageTest : JsonPageTest("unfollowSone.ajax", pageSupplier = ::UnfollowSoneAjaxPage) {
13
14         @Test
15         fun `request without sone returns invalid-sone-id`() {
16                 assertThat(json.isSuccess, equalTo(false))
17                 assertThat(json.error, equalTo("invalid-sone-id"))
18         }
19
20         @Test
21         fun `request with invalid sone returns invalid-sone-id`() {
22                 addRequestParameter("sone", "invalid")
23                 assertThat(json.isSuccess, equalTo(false))
24                 assertThat(json.error, equalTo("invalid-sone-id"))
25         }
26
27         @Test
28         fun `request with valid sone unfollows sone`() {
29                 addSone(mock(), "sone-id")
30                 addRequestParameter("sone", "sone-id")
31                 assertThat(json.isSuccess, equalTo(true))
32                 verify(core).unfollowSone(currentSone, "sone-id")
33         }
34
35 }