1 package net.pterodactylus.sone.web.ajax
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
9 import org.mockito.Mockito.verify
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 assertThat(json.isSuccess, equalTo(false))
19 assertThat(json.error, equalTo("invalid-sone-id"))
23 fun `request with sone follows sone`() {
24 addSone(mock<Sone>().apply { whenever(id).thenReturn("sone-id") })
25 addRequestParameter("sone", "sone-id")
26 assertThat(json.isSuccess, equalTo(true))
27 verify(core).followSone(currentSone, "sone-id")
31 fun `request with sone makes sone as known`() {
32 val sone = mock<Sone>()
33 addSone(sone, "sone-id")
34 addRequestParameter("sone", "sone-id")
35 assertThat(json.isSuccess, equalTo(true))
36 verify(core).markSoneKnown(sone)