1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.main.*
4 import net.pterodactylus.sone.web.*
5 import net.pterodactylus.sone.web.page.*
6 import org.hamcrest.MatcherAssert.*
7 import org.hamcrest.Matchers.*
10 class ErrorPagesTest {
12 private val webPageTest = WebPageTest()
14 private fun testPage(page: (WebInterface, Loaders, TemplateRenderer) -> FreenetTemplatePage, test: (FreenetTemplatePage) -> Unit) =
16 test(page(webInterface, loaders, templateRenderer))
20 fun `invalid page returns correct path`() {
21 testPage(::InvalidPage) { page ->
22 assertThat(page.path, equalTo("invalid.html"))
27 fun `invalid page returns correct title`() {
28 testPage(::InvalidPage) { page ->
29 assertThat(page.getPageTitle(webPageTest.freenetRequest), equalTo("Page.Invalid.Title"))
34 fun `invalid page is annotated with correct template path`() {
35 testPage(::InvalidPage) { page ->
36 assertThat(page.templatePath, equalTo("/templates/invalid.html"))
41 fun `no permission page returns correct path`() {
42 testPage(::NoPermissionPage) { page ->
43 assertThat(page.path, equalTo("noPermission.html"))
48 fun `no permission page returns correct title`() {
49 testPage(::NoPermissionPage) { page ->
50 assertThat(page.getPageTitle(webPageTest.freenetRequest), equalTo("Page.NoPermission.Title"))
55 fun `no permission page is annotated with correct template path`() {
56 testPage(::NoPermissionPage) { page ->
57 assertThat(page.templatePath, equalTo("/templates/noPermission.html"))
62 fun `empty image title page returns correct path`() {
63 testPage(::EmptyImageTitlePage) { page ->
64 assertThat(page.path, equalTo("emptyImageTitle.html"))
69 fun `empty image title page returns correct page title`() {
70 testPage(::EmptyImageTitlePage) { page ->
71 assertThat(page.getPageTitle(webPageTest.freenetRequest), equalTo("Page.EmptyImageTitle.Title"))
76 fun `empty image title page is annotated with correct template path`() {
77 testPage(::EmptyImageTitlePage) { page ->
78 assertThat(page.templatePath, equalTo("/templates/emptyImageTitle.html"))
83 fun `empty album title page returns correct path`() {
84 testPage(::EmptyAlbumTitlePage) { page ->
85 assertThat(page.path, equalTo("emptyAlbumTitle.html"))
90 fun `empty album title page returns correct page title`() {
91 testPage(::EmptyAlbumTitlePage) { page ->
92 assertThat(page.getPageTitle(webPageTest.freenetRequest), equalTo("Page.EmptyAlbumTitle.Title"))
97 fun `empty album title page is annotated with correct template path`() {
98 testPage(::EmptyAlbumTitlePage) { page ->
99 assertThat(page.templatePath, equalTo("/templates/emptyAlbumTitle.html"))