X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FPageToadletRegistryTest.kt;h=2134661f5d812da00de44c401afc4be3a2d68384;hp=5a19c7f96feb2f2e0573a12b6886d0177d82be07;hb=HEAD;hpb=33fe718540dfcc498c06c44c957ccb76bee57eae diff --git a/src/test/kotlin/net/pterodactylus/sone/web/PageToadletRegistryTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/PageToadletRegistryTest.kt index 5a19c7f..2134661 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/PageToadletRegistryTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/PageToadletRegistryTest.kt @@ -5,7 +5,6 @@ import freenet.clients.http.* import net.pterodactylus.sone.main.* import net.pterodactylus.sone.test.* import net.pterodactylus.sone.web.page.* -import net.pterodactylus.util.web.* import org.junit.* import org.junit.rules.* import org.mockito.Mockito.* @@ -36,7 +35,7 @@ class PageToadletRegistryTest { verify(pageMaker).addNavigationCategory("/Sone/index.html", "Navigation.Menu.Sone.Name", "Navigation.Menu.Sone.Tooltip", sonePlugin) } - private val page = TestPage() + private val page = TestPage() @Test fun `adding a page without menuname will add it correctly`() { @@ -101,6 +100,17 @@ class PageToadletRegistryTest { } @Test + fun `adding a debug page and activating debug mode twice will add it to the container once`() { + val toadlet = createPageToadlet() + whenever(pageToadletFactory.createPageToadlet(page)).thenReturn(toadlet) + pageToadletRegistry.addDebugPage(page) + pageToadletRegistry.registerToadlets() + pageToadletRegistry.activateDebugMode() + pageToadletRegistry.activateDebugMode() + verify(toadletContainer, times(1)).register(toadlet, null, "/Sone/", true, false) + } + + @Test fun `debug pages are ungegistered from the container`() { val toadlet = createPageToadlet() whenever(pageToadletFactory.createPageToadlet(page)).thenReturn(toadlet) @@ -136,10 +146,4 @@ class PageToadletRegistryTest { whenever(this.menuName).thenReturn(menuName) } - private class TestPage : Page { - override fun getPath() = "" - override fun isPrefixPage() = false - override fun handleRequest(freenetRequest: FreenetRequest, response: Response) = response - } - }