X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FMarkAsKnownAjaxPageTest.kt;h=6ed2326c60ddf758ea6a31cdd8e91115cb566ce2;hp=c867c9629fde85f979f126c2edf6c297319ef5b6;hb=6dba6475932d017987f7a72cb8537547b716a3f3;hpb=5f4783e98cd87731caebfc0902095932e82010f6 diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPageTest.kt index c867c96..6ed2326 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPageTest.kt @@ -3,10 +3,13 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.PostReply import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever +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.Mockito.any import org.mockito.Mockito.never @@ -19,15 +22,14 @@ class MarkAsKnownAjaxPageTest : JsonPageTest("markAsKnown.ajax", requiresLogin = @Test fun `request without type results in invalid-type`() { - assertThat(json.isSuccess, equalTo(false)) - assertThat(json.error, equalTo("invalid-type")) + assertThatJsonFailed("invalid-type") } @Test fun `request with unknown sone returns successfully`() { addRequestParameter("type", "sone") addRequestParameter("id", "invalid") - assertThat(json.isSuccess, equalTo(true)) + assertThatJsonIsSuccessful() verify(core, never()).markSoneKnown(any()) } @@ -39,7 +41,7 @@ class MarkAsKnownAjaxPageTest : JsonPageTest("markAsKnown.ajax", requiresLogin = val sone2 = mock().apply { whenever(id).thenReturn("sone-id2") } addSone(sone1) addSone(sone2) - assertThat(json.isSuccess, equalTo(true)) + assertThatJsonIsSuccessful() verify(core).markSoneKnown(sone1) verify(core).markSoneKnown(sone2) } @@ -52,7 +54,7 @@ class MarkAsKnownAjaxPageTest : JsonPageTest("markAsKnown.ajax", requiresLogin = val post2 = mock() addPost(post1, "post1") addPost(post2, "post2") - assertThat(json.isSuccess, equalTo(true)) + assertThatJsonIsSuccessful() verify(core).markPostKnown(post1) verify(core).markPostKnown(post2) } @@ -65,9 +67,14 @@ class MarkAsKnownAjaxPageTest : JsonPageTest("markAsKnown.ajax", requiresLogin = val reply2 = mock() addReply(reply1, "reply1") addReply(reply2, "reply2") - assertThat(json.isSuccess, equalTo(true)) + assertThatJsonIsSuccessful() verify(core).markReplyKnown(reply1) verify(core).markReplyKnown(reply2) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }