X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FAboutPageTest.kt;h=a2fd178ad10427fc79a6ad7e3ed298fb4be2716a;hp=142bf819464a6af81fc691190706c355bac2203b;hb=bce70170ce5ddaa142e67fcc67985215e1eadac2;hpb=2dd40fba7031cffb35a5156435547a5d964535c9 diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/AboutPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/AboutPageTest.kt index 142bf81..a2fd178 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/AboutPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/AboutPageTest.kt @@ -1,16 +1,19 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.main.SonePlugin.PluginHomepage -import net.pterodactylus.sone.main.SonePlugin.PluginVersion -import net.pterodactylus.sone.main.SonePlugin.PluginYear +import net.pterodactylus.sone.main.* +import net.pterodactylus.sone.test.getInstance +import net.pterodactylus.sone.test.isProvidedByMock +import net.pterodactylus.sone.web.baseInjector +import net.pterodactylus.sone.web.page.* import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Test /** * Unit test for [AboutPage]. */ -class AboutPageTest: WebPageTest({ template, webInterface -> AboutPage(template, webInterface, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) { +class AboutPageTest : WebPageTest({ template, webInterface, loaders, templateRenderer -> AboutPage(template, webInterface, loaders, templateRenderer, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) { companion object { private const val version = "0.1.2" @@ -46,4 +49,24 @@ class AboutPageTest: WebPageTest({ template, webInterface -> AboutPage(template, assertThat(templateContext["year"], equalTo(year)) } + @Test + fun `about page can be created by dependency injection`() { + val injector = baseInjector.createChildInjector( + PluginVersion::class.isProvidedByMock(), + PluginYear::class.isProvidedByMock(), + PluginHomepage::class.isProvidedByMock() + ) + assertThat(injector.getInstance(), notNullValue()) + } + + @Test + fun `page is annotated with correct menuname`() { + assertThat(page.menuName, equalTo("About")) + } + + @Test + fun `page is annotated with correct template path`() { + assertThat(page.templatePath, equalTo("/templates/about.html")) + } + }