Move assertions to base class
[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                 assertThatJsonFailed("invalid-sone-id")
17         }
18
19         @Test
20         fun `request with invalid sone returns invalid-sone-id`() {
21                 addRequestParameter("sone", "invalid")
22                 assertThatJsonFailed("invalid-sone-id")
23         }
24
25         @Test
26         fun `request with valid sone unfollows sone`() {
27                 addSone(mock(), "sone-id")
28                 addRequestParameter("sone", "sone-id")
29                 assertThatJsonIsSuccessful()
30                 verify(core).unfollowSone(currentSone, "sone-id")
31         }
32
33 }