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 assertThat(json.isSuccess, equalTo(false))
17 assertThat(json.error, equalTo("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 assertThat(json.isSuccess, equalTo(true))
26 assertThat(profile.getFieldByName("foo"), nullValue())
27 verify(currentSone).profile = profile
28 verify(core).touchConfiguration()