1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.data.Sone
4 import net.pterodactylus.sone.test.getInstance
5 import net.pterodactylus.sone.test.mock
6 import net.pterodactylus.sone.test.whenever
7 import net.pterodactylus.sone.web.baseInjector
8 import org.hamcrest.MatcherAssert.assertThat
9 import org.hamcrest.Matchers.equalTo
10 import org.hamcrest.Matchers.notNullValue
12 import org.mockito.Mockito.verify
15 * Unit test for [UnfollowSoneAjaxPage].
17 class UnfollowSoneAjaxPageTest : JsonPageTest("unfollowSone.ajax", pageSupplier = ::UnfollowSoneAjaxPage) {
20 fun `request without sone returns invalid-sone-id`() {
21 assertThatJsonFailed("invalid-sone-id")
25 fun `request with invalid sone returns invalid-sone-id`() {
26 addRequestParameter("sone", "invalid")
27 assertThatJsonFailed("invalid-sone-id")
31 fun `request with valid sone unfollows sone`() {
32 addSone(mock<Sone>().apply { whenever(id).thenReturn("sone-id") })
33 addRequestParameter("sone", "sone-id")
34 assertThatJsonIsSuccessful()
35 verify(core).unfollowSone(currentSone, "sone-id")
39 fun `page can be created by dependency injection`() {
40 assertThat(baseInjector.getInstance<UnfollowSoneAjaxPage>(), notNullValue())