X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnbookmarkAjaxPageTest.kt;h=b54981f9daf770a633e49e2beb81cf43975b41f4;hp=703b9cd917bc822b8275901b76b4c9734d1a7f23;hb=c0776d261e552e1361bca845be0f47e4c26b5e9d;hpb=21dedb25f4c512799fa35cb60581611bb2c92716 diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPageTest.kt index 703b9cd..b54981f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPageTest.kt @@ -1,9 +1,12 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.data.Post +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.web.baseInjector import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Test import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.eq @@ -17,21 +20,19 @@ class UnbookmarkAjaxPageTest : JsonPageTest("unbookmark.ajax", requiresLogin = f @Test fun `request without post id results in invalid-post-id`() { - assertThat(json.isSuccess, equalTo(false)) - assertThat(json.error, equalTo("invalid-post-id")) + assertThatJsonFailed("invalid-post-id") } @Test fun `request with empty post id results in invalid-post-id`() { addRequestParameter("post", "") - assertThat(json.isSuccess, equalTo(false)) - assertThat(json.error, equalTo("invalid-post-id")) + assertThatJsonFailed("invalid-post-id") } @Test - fun `request with invalid post id does not unbookmark anything but succeeds`() { + fun `request with invalid post id does not unbookmark anything and fails`() { addRequestParameter("post", "invalid") - assertThat(json.isSuccess, equalTo(true)) + assertThat(json.isSuccess, equalTo(false)) verify(core, never()).unbookmarkPost(any()) } @@ -40,8 +41,13 @@ class UnbookmarkAjaxPageTest : JsonPageTest("unbookmark.ajax", requiresLogin = f val post = mock() addPost(post, "post-id") addRequestParameter("post", "post-id") - assertThat(json.isSuccess, equalTo(true)) + assertThatJsonIsSuccessful() verify(core).unbookmarkPost(eq(post)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }