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