1 package net.pterodactylus.sone.web.ajax
3 import org.hamcrest.MatcherAssert.assertThat
4 import org.hamcrest.Matchers.equalTo
5 import org.hamcrest.Matchers.nullValue
7 import org.mockito.Mockito.verify
10 * Unit test for [DeleteProfileFieldAjaxPage].
12 class DeleteProfileFieldAjaxPageTest : JsonPageTest("deleteProfileField.ajax", pageSupplier = ::DeleteProfileFieldAjaxPage) {
15 fun `request without field id results in invalid field id error`() {
16 assertThatJsonFailed("invalid-field-id")
20 fun `request with valid field id results in field deletion`() {
21 profile.addField("foo")
22 val fieldId = profile.getFieldByName("foo")!!.id
23 addRequestParameter("field", fieldId)
24 assertThatJsonIsSuccessful()
25 assertThat(profile.getFieldByName("foo"), nullValue())
26 verify(currentSone).profile = profile
27 verify(core).touchConfiguration()