X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fnotification%2FNotificationHandlerModuleTest.kt;h=497ae1db4d82dc48c1d49241ab02a6721eb02d17;hb=8d9f18ad6233388b4b1beb4e457ad211015b90a4;hp=ea5db56169c4dce969fbd18041877eabf1fd8996;hpb=60b0b8a4b6954a0137b963397e144fd4ed82e3a8;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt index ea5db56..497ae1d 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt @@ -25,6 +25,7 @@ import net.pterodactylus.sone.core.event.* import net.pterodactylus.sone.data.* import net.pterodactylus.sone.data.Post.* import net.pterodactylus.sone.data.impl.* +import net.pterodactylus.sone.database.* import net.pterodactylus.sone.freenet.wot.* import net.pterodactylus.sone.main.* import net.pterodactylus.sone.notify.* @@ -37,7 +38,6 @@ import org.hamcrest.Matchers import org.hamcrest.Matchers.* import org.mockito.* import org.mockito.Mockito.* -import java.io.* import java.util.concurrent.* import java.util.concurrent.TimeUnit.* import java.util.function.* @@ -60,6 +60,7 @@ class NotificationHandlerModuleTest { WebOfTrustConnector::class.isProvidedBy(webOfTrustConnector), ScheduledExecutorService::class.withNameIsProvidedBy(ticker, "notification"), SoneTextParser::class.isProvidedByMock(), + PostReplyProvider::class.isProvidedByMock(), NotificationHandlerModule() ) @@ -75,9 +76,7 @@ class NotificationHandlerModuleTest { @Test fun `mark-post-known-during-first-start handler is created with correct action`() { - notificationManager.addNotification(object : AbstractNotification("first-start-notification") { - override fun render(writer: Writer?) = Unit - }) + notificationManager.firstStart() val handler = injector.getInstance() val post = mock() handler.newPostFound(NewPostFoundEvent(post)) @@ -464,4 +463,32 @@ class NotificationHandlerModuleTest { assertThat(injector.getInstance(), notNullValue()) } + @Test + fun `sone-mentioned notification is created as singleton`() { + injector.verifySingletonInstance>(named("soneMentioned")) + } + + @Test + fun `sone-mentioned notification has correct ID`() { + assertThat(injector.getInstance>(named("soneMentioned")).id, equalTo("mention-notification")) + } + + @Test + fun `sone-mentioned notification is not dismissable`() { + assertThat(injector.getInstance>(named("soneMentioned")).isDismissable, equalTo(false)) + } + + @Test + fun `sone-mentioned notification loads correct template`() { + loaders.templates += "/templates/notify/mentionNotification.html" to "<% posts>".asTemplate() + val notification = injector.getInstance>(named("soneMentioned")) + val posts = listOf(EmptyPost("1"), EmptyPost("2")).onEach(notification::add) + assertThat(notification.render(), equalTo(posts.toString())) + } + + @Test + fun `sone-mentioned handler is created as singleton`() { + injector.verifySingletonInstance() + } + }