1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.main.*
4 import net.pterodactylus.sone.test.*
5 import net.pterodactylus.sone.web.*
6 import net.pterodactylus.sone.web.page.*
7 import org.hamcrest.MatcherAssert.*
8 import org.hamcrest.Matchers.*
12 * Unit test for [AboutPage].
14 class AboutPageTest : WebPageTest({ webInterface, loaders, templateRenderer -> AboutPage(webInterface, loaders, templateRenderer, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) {
17 private const val version = "0.1.2"
18 private const val year = 1234
19 private const val homepage = "home://page"
23 fun `page returns correct path`() {
24 assertThat(page.path, equalTo("about.html"))
28 fun `page does not require login`() {
29 assertThat(page.requiresLogin(), equalTo(false))
33 fun `page sets correct version in template context`() {
34 page.processTemplate(freenetRequest, templateContext)
35 assertThat(templateContext["version"], equalTo<Any>(version))
39 fun `page sets correct homepage in template context`() {
40 page.processTemplate(freenetRequest, templateContext)
41 assertThat(templateContext["homepage"], equalTo<Any>(homepage))
45 fun `page sets correct year in template context`() {
46 page.processTemplate(freenetRequest, templateContext)
47 assertThat(templateContext["year"], equalTo<Any>(year))
51 fun `about page can be created by dependency injection`() {
52 val injector = baseInjector.createChildInjector(
53 PluginVersion::class.isProvidedByMock(),
54 PluginYear::class.isProvidedByMock(),
55 PluginHomepage::class.isProvidedByMock()
57 assertThat(injector.getInstance<AboutPage>(), notNullValue())
61 fun `page is annotated with correct menuname`() {
62 assertThat(page.menuName, equalTo("About"))
66 fun `page is annotated with correct template path`() {
67 assertThat(page.templatePath, equalTo("/templates/about.html"))