Add more tests for follow Sone page
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / pages / AboutPageTest.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.main.SonePlugin.PluginHomepage
4 import net.pterodactylus.sone.main.SonePlugin.PluginVersion
5 import net.pterodactylus.sone.main.SonePlugin.PluginYear
6 import net.pterodactylus.sone.web.pages.WebPageTest
7 import net.pterodactylus.sone.web.pages.AboutPage
8 import org.hamcrest.MatcherAssert.assertThat
9 import org.hamcrest.Matchers.equalTo
10 import org.junit.Test
11
12 /**
13  * Unit test for [AboutPage].
14  */
15 class AboutPageTest: WebPageTest() {
16
17         private val version = "0.1.2"
18         private val year = 1234
19         private val homepage = "home://page"
20         private val page = AboutPage(template, webInterface, PluginVersion(version), PluginYear(year), PluginHomepage(homepage))
21
22         @Test
23         fun `page returns correct path`() {
24                 assertThat(page.path, equalTo("about.html"))
25         }
26
27         @Test
28         fun `page does not require login`() {
29                 assertThat(page.requiresLogin(), equalTo(false))
30         }
31
32         @Test
33         fun `page sets correct version in template context`() {
34                 page.processTemplate(freenetRequest, templateContext)
35                 assertThat(templateContext["version"], equalTo<Any>(version))
36         }
37
38         @Test
39         fun `page sets correct homepage in template context`() {
40                 page.processTemplate(freenetRequest, templateContext)
41                 assertThat(templateContext["homepage"], equalTo<Any>(homepage))
42         }
43
44         @Test
45         fun `page sets correct year in template context`() {
46                 page.processTemplate(freenetRequest, templateContext)
47                 assertThat(templateContext["year"], equalTo<Any>(year))
48         }
49
50 }