X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftext%2FSoneMentionDetectorTest.kt;h=720823039d35831d1849838611e4b921957980d7;hp=6ae437bd44f86bf3926651b72b7d68417b10a555;hb=8bbd85568dc97aa6741835e45a40cc7a0e44691f;hpb=b5848fd116890f2b9434f169a16d203f24bfa94e diff --git a/src/test/kotlin/net/pterodactylus/sone/text/SoneMentionDetectorTest.kt b/src/test/kotlin/net/pterodactylus/sone/text/SoneMentionDetectorTest.kt index 6ae437b..7208230 100644 --- a/src/test/kotlin/net/pterodactylus/sone/text/SoneMentionDetectorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/text/SoneMentionDetectorTest.kt @@ -32,7 +32,8 @@ import kotlin.test.* @Suppress("UnstableApiUsage") class SoneMentionDetectorTest { - private val eventBus = EventBus() + private val caughtExceptions = mutableListOf() + private val eventBus = EventBus { exception, _ -> caughtExceptions += exception } private val soneProvider = TestSoneProvider() private val postProvider = TestPostProvider() private val soneTextParser = SoneTextParser(soneProvider, postProvider) @@ -143,6 +144,14 @@ class SoneMentionDetectorTest { } @Test + fun `detector does not emit event for reply without post`() { + val reply = emptyPostReply("text mentions sone://${localSone1.id} and sone://${localSone2.id}.", post = null) + eventBus.post(NewPostReplyFoundEvent(reply)) + assertThat(caughtExceptions, emptyIterable()) + assertThat(capturedFoundEvents, emptyIterable()) + } + + @Test fun `detector does not emit removed event when a post without mention is removed`() { val post = createPost() eventBus.post(PostRemovedEvent(post))