X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetNotificationsAjaxPageTest.kt;h=c9afbf090d99fa3a4d96c1063e0b5d4e4631d14c;hb=bf509980d5097e67d1a32f6b53bef052b396137f;hp=8084b654c4da0df42fc8868f145a50ab0e549d59;hpb=43278c5468221baa16946a5206c3a4e97d543010;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt index 8084b65..c9afbf0 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPageTest.kt @@ -3,8 +3,10 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.main.SonePlugin import net.pterodactylus.sone.test.argumentCaptor import net.pterodactylus.sone.test.get +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 net.pterodactylus.util.notify.Notification import net.pterodactylus.util.notify.TemplateNotification import net.pterodactylus.util.template.TemplateContext @@ -14,6 +16,7 @@ import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.containsInAnyOrder import org.hamcrest.Matchers.empty import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Test import org.mockito.ArgumentMatchers.any import org.mockito.Mockito.verify @@ -22,7 +25,9 @@ import java.io.Writer /** * Unit test for [GetNotificationsAjaxPage]. */ -class GetNotificationsAjaxPageTest : JsonPageTest("getNotifications.ajax", requiresLogin = false, needsFormPassword = false, pageSupplier = ::GetNotificationsAjaxPage) { +class GetNotificationsAjaxPageTest : JsonPageTest("getNotifications.ajax", requiresLogin = false, needsFormPassword = false) { + + override val page: JsonPage by lazy { GetNotificationsAjaxPage(webInterface, TemplateContextFactory()) } private val testNotifications = listOf( createNotification("n1", 2000, "t1", 5000, true), @@ -86,7 +91,6 @@ class GetNotificationsAjaxPageTest : JsonPageTest("getNotifications.ajax", requi @Test fun `template notifications are rendered correctly`() { - whenever(webInterface.templateContextFactory).thenReturn(TemplateContextFactory()) whenever(updateChecker.hasLatestVersion()).thenReturn(true) whenever(updateChecker.latestEdition).thenReturn(999) whenever(updateChecker.latestVersion).thenReturn(Version(0, 1, 2)) @@ -115,4 +119,9 @@ class GetNotificationsAjaxPageTest : JsonPageTest("getNotifications.ajax", requi assertThat(templateContext.value["notification"], equalTo(templateNotification)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }