1 package net.pterodactylus.sone.web.ajax
3 import net.pterodactylus.sone.test.*
4 import net.pterodactylus.sone.web.*
5 import org.hamcrest.MatcherAssert.*
6 import org.hamcrest.Matchers.*
8 import org.mockito.Mockito.*
11 * Unit test for [DeleteProfileFieldAjaxPage].
13 class DeleteProfileFieldAjaxPageTest : JsonPageTest("deleteProfileField.ajax", pageSupplier = ::DeleteProfileFieldAjaxPage) {
16 fun `request without field id results in invalid field id error`() {
17 assertThatJsonFailed("invalid-field-id")
21 fun `request with valid field id results in field deletion`() {
22 profile.addField("foo")
23 val fieldId = profile.getFieldByName("foo")!!.id
24 addRequestParameter("field", fieldId)
25 assertThatJsonIsSuccessful()
26 assertThat(profile.getFieldByName("foo"), nullValue())
27 verify(currentSone).profile = profile
28 verify(core).touchConfiguration()
32 fun `page can be created by dependency injection`() {
33 assertThat(baseInjector.getInstance<DeleteProfileFieldAjaxPage>(), notNullValue())