From: David ‘Bombe’ Roden Date: Fri, 12 Apr 2019 15:17:07 +0000 (+0200) Subject: ✅ Add basic test for FreenetTemplatePage X-Git-Tag: v79^2~62 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4c5a7fd8b4f2d2e223304b7ad4fb9829d011cbe9;p=Sone.git ✅ Add basic test for FreenetTemplatePage --- 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)) + } + +}