Optimize some imports
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / ajax / FollowSoneAjaxPageTest.kt
1 package net.pterodactylus.sone.web.ajax
2
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.*
8 import org.junit.*
9 import org.mockito.Mockito.*
10
11 /**
12  * Unit test for [FollowSoneAjaxPage].
13  */
14 class FollowSoneAjaxPageTest : JsonPageTest("followSone.ajax", pageSupplier = ::FollowSoneAjaxPage) {
15
16         @Test
17         fun `request without sone id results in invalid-sone-id`() {
18                 assertThatJsonFailed("invalid-sone-id")
19         }
20
21         @Test
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")
27         }
28
29         @Test
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)
36         }
37
38         @Test
39         fun `page can be created by dependency injection`() {
40                 assertThat(baseInjector.getInstance<FollowSoneAjaxPage>(), notNullValue())
41         }
42
43 }