Replace reply-specific interfaces with Kotlin versions
[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.data.Sone
4 import net.pterodactylus.sone.test.mock
5 import net.pterodactylus.sone.test.whenever
6 import org.hamcrest.MatcherAssert.assertThat
7 import org.hamcrest.Matchers.equalTo
8 import org.junit.Test
9 import org.mockito.Mockito.verify
10
11 /**
12  * Unit test for [UnfollowSoneAjaxPage].
13  */
14 class UnfollowSoneAjaxPageTest : JsonPageTest("unfollowSone.ajax", pageSupplier = ::UnfollowSoneAjaxPage) {
15
16         @Test
17         fun `request without sone returns invalid-sone-id`() {
18                 assertThatJsonFailed("invalid-sone-id")
19         }
20
21         @Test
22         fun `request with invalid sone returns invalid-sone-id`() {
23                 addRequestParameter("sone", "invalid")
24                 assertThatJsonFailed("invalid-sone-id")
25         }
26
27         @Test
28         fun `request with valid sone unfollows sone`() {
29                 addSone(mock<Sone>().apply { whenever(id).thenReturn("sone-id") })
30                 addRequestParameter("sone", "sone-id")
31                 assertThatJsonIsSuccessful()
32                 verify(core).unfollowSone(currentSone, "sone-id")
33         }
34
35 }