From 4c5a7fd8b4f2d2e223304b7ad4fb9829d011cbe9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 12 Apr 2019 17:17:07 +0200 Subject: [PATCH] =?utf8?q?=E2=9C=85=20Add=20basic=20test=20for=20FreenetTe?= =?utf8?q?mplatePage?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sone/web/page/FreenetTemplatePageTest.kt | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt diff --git a/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt new file mode 100644 index 0000000..f08d3ae --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt @@ -0,0 +1,78 @@ +package net.pterodactylus.sone.web.page + +import net.pterodactylus.sone.test.* +import org.hamcrest.MatcherAssert.* +import org.hamcrest.Matchers.* +import org.junit.* + +class FreenetTemplatePageTest { + + @Test + fun `path is exposed correctly`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.path, equalTo("/test/path")) + } + + @Test + fun `getPageTitle() default implementation returns null`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.getPageTitle(mock()), nullValue()) + } + + @Test + fun `isPrefixPage() default implementation returns false`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.isPrefixPage, equalTo(false)) + } + + @Test + fun `getStylesheets() default implementation returns empty collection`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.styleSheets, empty()) + } + + @Test + fun `getShortcutIcon() default implementation returns null`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.shortcutIcon, nullValue()) + } + + @Test + fun `getRedirectTarget() default implementation returns null`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.getRedirectTarget(mock()), nullValue()) + } + + @Test + fun `getAdditionalLinkNodes() default implementation returns empty collection`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.getAdditionalLinkNodes(mock()), empty()) + } + + @Test + fun `isFullAccessOnly() default implementation returns false`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.isFullAccessOnly, equalTo(false)) + } + + @Test + fun `isLinkExcepted() default implementation returns false`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.isLinkExcepted(mock()), equalTo(false)) + } + + @Test + fun `isEnabled() returns true if full access only is false`() { + val page = FreenetTemplatePage("/test/path", null, null, null) + assertThat(page.isEnabled(mock()), equalTo(true)) + } + + @Test + fun `isEnabled() returns false if full access only is true`() { + val page = object : FreenetTemplatePage("/test/path", null, null, null) { + override fun isFullAccessOnly() = true + } + assertThat(page.isEnabled(mock()), equalTo(false)) + } + +} -- 2.7.4