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 [LockSoneAjaxPage].
14 class LockSoneAjaxPageTest : JsonPageTest("lockSone.ajax", requiresLogin = false, pageSupplier = ::LockSoneAjaxPage) {
17 fun `request without valid sone results in invalid-sone-id`() {
18 assertThatJsonFailed("invalid-sone-id")
22 fun `request with valid sone id results in locked sone`() {
23 val sone = mock<Sone>()
24 addLocalSone(sone, "sone-id")
25 addRequestParameter("sone", "sone-id")
26 assertThatJsonIsSuccessful()
27 verify(core).lockSone(sone)
31 fun `page can be created by dependency injection`() {
32 assertThat(baseInjector.getInstance<LockSoneAjaxPage>(), notNullValue())