From: David ‘Bombe’ Roden Date: Fri, 24 Mar 2017 18:26:20 +0000 (+0100) Subject: Add some tests and fix names of tests X-Git-Tag: 0.9.7^2~283 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9e3a4c505fa6a8a5e3fb8fb00b284c98e010a9d8;p=Sone.git Add some tests and fix names of tests --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/DismissNotificationPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/DismissNotificationPageTest.kt index 58e1eed..3c19f5c 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/DismissNotificationPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/DismissNotificationPageTest.kt @@ -4,6 +4,8 @@ import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import net.pterodactylus.util.notify.Notification import net.pterodactylus.util.web.Method.GET +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo import org.junit.Test import org.mockito.Mockito.never import org.mockito.Mockito.verify @@ -11,7 +13,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DismissNotificationPage]. */ -class DismissNotificationPageTest : WebPageTest() { +class DismissNotificationPageTest: WebPageTest() { private val page = DismissNotificationPage(template, webInterface) private val notification = mock() @@ -19,6 +21,22 @@ class DismissNotificationPageTest : WebPageTest() { override fun getPage() = page @Test + fun `page returns correct path`() { + assertThat(page.path, equalTo("dismissNotification.html")) + } + + @Test + fun `page does not require login`() { + assertThat(page.requiresLogin(), equalTo(false)) + } + + @Test + fun `page returns correct title`() { + whenever(l10n.getString("Page.DismissNotification.Title")).thenReturn("dismiss notification page") + assertThat(page.getPageTitle(freenetRequest), equalTo("dismiss notification page")) + } + + @Test fun `get request with invalid notification ID redirects to return page`() { request("", GET) addHttpRequestParameter("returnPage", "return.html") @@ -26,7 +44,7 @@ class DismissNotificationPageTest : WebPageTest() { } @Test - fun `get request with dismissible notification dismisses the notification and redirects to return page`() { + fun `get request with non-dismissible notification never dismisses the notification but redirects to return page`() { request("", GET) addNotification("notification-id", notification) addHttpRequestParameter("notification", "notification-id") @@ -37,7 +55,7 @@ class DismissNotificationPageTest : WebPageTest() { } @Test - fun `get request with non dismissible notification redirects to return page`() { + fun `get request with dismissible notification dismisses the notification and redirects to return page`() { request("", GET) whenever(notification.isDismissable).thenReturn(true) addNotification("notification-id", notification)