✅ Add basic test for FreenetTemplatePage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 12 Apr 2019 15:17:07 +0000 (17:17 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 12 Apr 2019 15:17:07 +0000 (17:17 +0200)
src/test/kotlin/net/pterodactylus/sone/web/page/FreenetTemplatePageTest.kt [new file with mode: 0644]

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 (file)
index 0000000..f08d3ae
--- /dev/null
@@ -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))
+       }
+
+}