Move assertions to base class
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / ajax / DeleteProfileFieldAjaxPageTest.kt
1 package net.pterodactylus.sone.web.ajax
2
3 import org.hamcrest.MatcherAssert.assertThat
4 import org.hamcrest.Matchers.equalTo
5 import org.hamcrest.Matchers.nullValue
6 import org.junit.Test
7 import org.mockito.Mockito.verify
8
9 /**
10  * Unit test for [DeleteProfileFieldAjaxPage].
11  */
12 class DeleteProfileFieldAjaxPageTest : JsonPageTest("deleteProfileField.ajax", pageSupplier = ::DeleteProfileFieldAjaxPage) {
13
14         @Test
15         fun `request without field id results in invalid field id error`() {
16                 assertThatJsonFailed("invalid-field-id")
17         }
18
19         @Test
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()
28         }
29
30 }