1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.test.*
5 import net.pterodactylus.sone.web.*
6 import org.hamcrest.MatcherAssert.*
7 import org.hamcrest.Matchers.*
9 import org.mockito.Mockito.*
12 * Unit test for [FollowSoneAjaxPage].
14 class FollowSoneAjaxPageTest : JsonPageTest("followSone.ajax", pageSupplier = ::FollowSoneAjaxPage) {
17 fun `request without sone id results in invalid-sone-id`() {
18 assertThatJsonFailed("invalid-sone-id")
22 fun `request with sone follows sone`() {
23 addSone(mock<Sone>().apply { whenever(id).thenReturn("sone-id") })
24 addRequestParameter("sone", "sone-id")
25 assertThatJsonIsSuccessful()
26 verify(core).followSone(currentSone, "sone-id")
30 fun `request with sone makes sone as known`() {
31 val sone = mock<Sone>()
32 addSone(sone, "sone-id")
33 addRequestParameter("sone", "sone-id")
34 assertThatJsonIsSuccessful()
35 verify(core).markSoneKnown(sone)
39 fun `page can be created by dependency injection`() {
40 assertThat(baseInjector.getInstance<FollowSoneAjaxPage>(), notNullValue())