From e7afeda8d0658bd4c392803cf444f5810fe18471 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 12 Apr 2019 15:55:01 +0200 Subject: [PATCH] =?utf8?q?=E2=9C=85=20Add=20test=20for=20PageToadletFactor?= =?utf8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sone/web/page/PageToadletFactoryTest.kt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/test/kotlin/net/pterodactylus/sone/web/page/PageToadletFactoryTest.kt 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")) + } + +} -- 2.7.4