From: David ‘Bombe’ Roden Date: Fri, 12 Apr 2019 13:55:01 +0000 (+0200) Subject: ✅ Add test for PageToadletFactory X-Git-Tag: v79^2~66 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e7afeda8d0658bd4c392803cf444f5810fe18471;p=Sone.git ✅ Add test for PageToadletFactory --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/page/PageToadletFactoryTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/page/PageToadletFactoryTest.kt new file mode 100644 index 0000000..93047cb --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/web/page/PageToadletFactoryTest.kt @@ -0,0 +1,42 @@ +package net.pterodactylus.sone.web.page + +import freenet.client.HighLevelSimpleClient +import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.test.whenever +import net.pterodactylus.util.web.Page +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.nullValue +import org.junit.Test + +private val highLevelSimpleClient = mock() +private const val pathPrefix = "/some/prefix/" + +class PageToadletFactoryTest { + + private val pageToadletFactory = PageToadletFactory(highLevelSimpleClient, pathPrefix) + + @Test + fun `page toadlet without menu name is created without menu name`() { + val page = mock>() + val pageToadlet = pageToadletFactory.createPageToadlet(page) + assertThat(pageToadlet.menuName, nullValue()) + } + + @Test + fun `page toadlet with menu name is created with menu name`() { + val page = mock>() + val pageToadlet = pageToadletFactory.createPageToadlet(page, "testName") + assertThat(pageToadlet.menuName, equalTo("testName")) + } + + @Test + fun `path prefix is handed down correctly`() { + val page = mock>().apply { + whenever(path).thenReturn("path") + } + val pageToadlet = pageToadletFactory.createPageToadlet(page) + assertThat(pageToadlet.path(), equalTo("/some/prefix/path")) + } + +}