X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpage%2FPageToadletFactoryTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpage%2FPageToadletFactoryTest.kt;h=93047cbdfc7b397940d6a64b996d94e32df252e4;hb=e7afeda8d0658bd4c392803cf444f5810fe18471;hp=0000000000000000000000000000000000000000;hpb=a6920549304a8d8de7bd3529de09cd1b8ee364e7;p=Sone.git 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")) + } + +}