♻️ Use handler for sone-mentioned notifications
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / notification / NotificationHandlerModuleTest.kt
index 7d96208..497ae1d 100644 (file)
@@ -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.*
@@ -59,6 +60,7 @@ class NotificationHandlerModuleTest {
                        WebOfTrustConnector::class.isProvidedBy(webOfTrustConnector),
                        ScheduledExecutorService::class.withNameIsProvidedBy(ticker, "notification"),
                        SoneTextParser::class.isProvidedByMock(),
+                       PostReplyProvider::class.isProvidedByMock(),
                        NotificationHandlerModule()
        )
 
@@ -461,4 +463,32 @@ class NotificationHandlerModuleTest {
                assertThat(injector.getInstance<SoneMentionDetector>(), notNullValue())
        }
 
+       @Test
+       fun `sone-mentioned notification is created as singleton`() {
+               injector.verifySingletonInstance<ListNotification<Post>>(named("soneMentioned"))
+       }
+
+       @Test
+       fun `sone-mentioned notification has correct ID`() {
+               assertThat(injector.getInstance<ListNotification<Post>>(named("soneMentioned")).id, equalTo("mention-notification"))
+       }
+
+       @Test
+       fun `sone-mentioned notification is not dismissable`() {
+               assertThat(injector.getInstance<ListNotification<Post>>(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<ListNotification<Post>>(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<SoneMentionedHandler>()
+       }
+
 }