1 package net.pterodactylus.sone.web
3 import net.pterodactylus.sone.test.mock
4 import net.pterodactylus.sone.test.whenever
5 import net.pterodactylus.util.notify.Notification
6 import net.pterodactylus.util.web.Method.GET
8 import org.mockito.Mockito.never
9 import org.mockito.Mockito.verify
12 * Unit test for [DismissNotificationPage].
14 class DismissNotificationPageTest : WebPageTest() {
16 private val page = DismissNotificationPage(template, webInterface)
17 private val notification = mock<Notification>()
19 override fun getPage() = page
22 fun `get request with invalid notification ID redirects to return page`() {
24 addHttpRequestParameter("returnPage", "return.html")
25 verifyRedirect("return.html")
29 fun `get request with dismissible notification dismisses the notification and redirects to return page`() {
31 addNotification("notification-id", notification)
32 addHttpRequestParameter("notification", "notification-id")
33 addHttpRequestParameter("returnPage", "return.html")
34 verifyRedirect("return.html") {
35 verify(notification, never()).dismiss()
40 fun `get request with non dismissible notification redirects to return page`() {
42 whenever(notification.isDismissable).thenReturn(true)
43 addNotification("notification-id", notification)
44 addHttpRequestParameter("notification", "notification-id")
45 addHttpRequestParameter("returnPage", "return.html")
46 verifyRedirect("return.html") {
47 verify(notification).dismiss()