Fix tests by parsing the created JSON reply
[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 org.hamcrest.MatcherAssert.assertThat
7 import org.hamcrest.Matchers.equalTo
8 import org.junit.Test
9
10 /**
11  * Unit test for [AboutPage].
12  */
13 class AboutPageTest: WebPageTest({ template, webInterface -> AboutPage(template, webInterface, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) {
14
15         companion object {
16                 private const val version = "0.1.2"
17                 private const val year = 1234
18                 private const val homepage = "home://page"
19         }
20
21         @Test
22         fun `page returns correct path`() {
23                 assertThat(page.path, equalTo("about.html"))
24         }
25
26         @Test
27         fun `page does not require login`() {
28                 assertThat(page.requiresLogin(), equalTo(false))
29         }
30
31         @Test
32         fun `page sets correct version in template context`() {
33                 page.processTemplate(freenetRequest, templateContext)
34                 assertThat(templateContext["version"], equalTo<Any>(version))
35         }
36
37         @Test
38         fun `page sets correct homepage in template context`() {
39                 page.processTemplate(freenetRequest, templateContext)
40                 assertThat(templateContext["homepage"], equalTo<Any>(homepage))
41         }
42
43         @Test
44         fun `page sets correct year in template context`() {
45                 page.processTemplate(freenetRequest, templateContext)
46                 assertThat(templateContext["year"], equalTo<Any>(year))
47         }
48
49 }