From: David ‘Bombe’ Roden Date: Fri, 24 Mar 2017 19:00:11 +0000 (+0100) Subject: Add some tests X-Git-Tag: 0.9.7^2~281 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ba52e76733494d39ea693d51fdb9a5f14eb10674;p=Sone.git Add some tests --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DistrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DistrustPageTest.kt index b5af91a..3057a63 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DistrustPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DistrustPageTest.kt @@ -2,21 +2,40 @@ package net.pterodactylus.sone.web import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.test.whenever import net.pterodactylus.util.web.Method.GET import net.pterodactylus.util.web.Method.POST +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo import org.junit.Test import org.mockito.Mockito.verify /** * Unit test for [DistrustPage]. */ -class DistrustPageTest : WebPageTest() { +class DistrustPageTest: WebPageTest() { private val page = DistrustPage(template, webInterface) override fun getPage() = page @Test + fun `page returns correct path`() { + assertThat(page.path, equalTo("distrust.html")) + } + + @Test + fun `page requires login`() { + assertThat(page.requiresLogin(), equalTo(true)) + } + + @Test + fun `page returns correct title`() { + whenever(l10n.getString("Page.Distrust.Title")).thenReturn("distrust page title") + assertThat(page.getPageTitle(freenetRequest), equalTo("distrust page title")) + } + + @Test fun `get request does not redirect`() { request("", GET) page.handleRequest(freenetRequest, templateContext)