Moves test cases to commonTest
This commit is contained in:
+70
-71
@@ -20,13 +20,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.commons.richtext
|
package com.vitorpamplona.amethyst.commons.richtext
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import com.vitorpamplona.amethyst.commons.model.EmptyTagList
|
import com.vitorpamplona.amethyst.commons.model.EmptyTagList
|
||||||
import org.junit.Assert
|
import kotlin.test.DefaultAsserter.assertTrue
|
||||||
import org.junit.Test
|
import kotlin.test.Test
|
||||||
import org.junit.runner.RunWith
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class GalleryParserTest {
|
class GalleryParserTest {
|
||||||
@Test
|
@Test
|
||||||
fun testMixedImageAndVideoRenderedIndividually() {
|
fun testMixedImageAndVideoRenderedIndividually() {
|
||||||
@@ -39,23 +38,23 @@ class GalleryParserTest {
|
|||||||
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
||||||
|
|
||||||
// Should have 3 paragraphs (text, image, video)
|
// Should have 3 paragraphs (text, image, video)
|
||||||
Assert.assertEquals(3, state.paragraphs.size)
|
assertEquals(3, state.paragraphs.size)
|
||||||
|
|
||||||
// First paragraph is text
|
// First paragraph is text
|
||||||
Assert.assertTrue(state.paragraphs[0] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[0] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals(1, state.paragraphs[0].words.size)
|
assertEquals(1, state.paragraphs[0].words.size)
|
||||||
|
|
||||||
// Second paragraph is image (rendered individually, not as gallery)
|
// Second paragraph is image (rendered individually, not as gallery)
|
||||||
Assert.assertTrue(state.paragraphs[1] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[1] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals(1, state.paragraphs[1].words.size)
|
assertEquals(1, state.paragraphs[1].words.size)
|
||||||
Assert.assertTrue(state.paragraphs[1].words[0] is ImageSegment)
|
assertTrue(state.paragraphs[1].words[0] is ImageSegment)
|
||||||
Assert.assertEquals("https://image.tmdb.org/t/p/original/ekfIcBvqfqKbI6m227NFipBNh7O.jpg", state.paragraphs[1].words[0].segmentText)
|
assertEquals("https://image.tmdb.org/t/p/original/ekfIcBvqfqKbI6m227NFipBNh7O.jpg", state.paragraphs[1].words[0].segmentText)
|
||||||
|
|
||||||
// Third paragraph is video (rendered individually)
|
// Third paragraph is video (rendered individually)
|
||||||
Assert.assertTrue(state.paragraphs[2] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[2] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals(1, state.paragraphs[2].words.size)
|
assertEquals(1, state.paragraphs[2].words.size)
|
||||||
Assert.assertTrue(state.paragraphs[2].words[0] is VideoSegment)
|
assertTrue(state.paragraphs[2].words[0] is VideoSegment)
|
||||||
Assert.assertEquals("https://archive.org/download/cinema-horror-sci-fi/Renfield.2023.ia.mp4", state.paragraphs[2].words[0].segmentText)
|
assertEquals("https://archive.org/download/cinema-horror-sci-fi/Renfield.2023.ia.mp4", state.paragraphs[2].words[0].segmentText)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -72,27 +71,27 @@ class GalleryParserTest {
|
|||||||
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
||||||
|
|
||||||
// Should have 6 paragraphs (text, image, video, text, image, video)
|
// Should have 6 paragraphs (text, image, video, text, image, video)
|
||||||
Assert.assertEquals(6, state.paragraphs.size)
|
assertEquals(6, state.paragraphs.size)
|
||||||
|
|
||||||
// First set: text, image, video
|
// First set: text, image, video
|
||||||
Assert.assertTrue(state.paragraphs[0] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[0] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals(1, state.paragraphs[0].words.size)
|
assertEquals(1, state.paragraphs[0].words.size)
|
||||||
Assert.assertTrue(state.paragraphs[1] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[1] !is ImageGalleryParagraph)
|
||||||
Assert.assertTrue(state.paragraphs[1].words[0] is ImageSegment)
|
assertTrue(state.paragraphs[1].words[0] is ImageSegment)
|
||||||
Assert.assertEquals("https://image.tmdb.org/t/p/original/ekfIcBvqfqKbI6m227NFipBNh7O.jpg", state.paragraphs[1].words[0].segmentText)
|
assertEquals("https://image.tmdb.org/t/p/original/ekfIcBvqfqKbI6m227NFipBNh7O.jpg", state.paragraphs[1].words[0].segmentText)
|
||||||
Assert.assertTrue(state.paragraphs[2] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[2] !is ImageGalleryParagraph)
|
||||||
Assert.assertTrue(state.paragraphs[2].words[0] is VideoSegment)
|
assertTrue(state.paragraphs[2].words[0] is VideoSegment)
|
||||||
Assert.assertEquals("https://archive.org/download/cinema-horror-sci-fi/Renfield.2023.ia.mp4", state.paragraphs[2].words[0].segmentText)
|
assertEquals("https://archive.org/download/cinema-horror-sci-fi/Renfield.2023.ia.mp4", state.paragraphs[2].words[0].segmentText)
|
||||||
|
|
||||||
// Second set: text, image, video
|
// Second set: text, image, video
|
||||||
Assert.assertTrue(state.paragraphs[3] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[3] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals(1, state.paragraphs[3].words.size)
|
assertEquals(1, state.paragraphs[3].words.size)
|
||||||
Assert.assertTrue(state.paragraphs[4] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[4] !is ImageGalleryParagraph)
|
||||||
Assert.assertTrue(state.paragraphs[4].words[0] is ImageSegment)
|
assertTrue(state.paragraphs[4].words[0] is ImageSegment)
|
||||||
Assert.assertEquals("https://image.tmdb.org/t/p/original/ekfIcBvqfqKbI6m227NFipBNh7O.jpg", state.paragraphs[4].words[0].segmentText)
|
assertEquals("https://image.tmdb.org/t/p/original/ekfIcBvqfqKbI6m227NFipBNh7O.jpg", state.paragraphs[4].words[0].segmentText)
|
||||||
Assert.assertTrue(state.paragraphs[5] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[5] !is ImageGalleryParagraph)
|
||||||
Assert.assertTrue(state.paragraphs[5].words[0] is VideoSegment)
|
assertTrue(state.paragraphs[5].words[0] is VideoSegment)
|
||||||
Assert.assertEquals("https://archive.org/download/cinema-horror-sci-fi/Renfield.2023.ia.mp4", state.paragraphs[5].words[0].segmentText)
|
assertEquals("https://archive.org/download/cinema-horror-sci-fi/Renfield.2023.ia.mp4", state.paragraphs[5].words[0].segmentText)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -106,13 +105,13 @@ class GalleryParserTest {
|
|||||||
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
||||||
|
|
||||||
// Should have 2 image segments (image + video URLs)
|
// Should have 2 image segments (image + video URLs)
|
||||||
Assert.assertEquals(2, state.paragraphs.size)
|
assertEquals(2, state.paragraphs.size)
|
||||||
|
|
||||||
// Should render as gallery (1 gallery with 2 images)
|
// Should render as gallery (1 gallery with 2 images)
|
||||||
Assert.assertTrue("Should render 1 gallery", state.paragraphs[1] is ImageGalleryParagraph)
|
assertTrue("Should render 1 gallery", state.paragraphs[1] is ImageGalleryParagraph)
|
||||||
Assert.assertEquals("Gallery should contain 2 images", 2, state.paragraphs[1].words.size)
|
assertEquals(2, state.paragraphs[1].words.size, "Gallery should contain 2 images")
|
||||||
Assert.assertEquals("https://example.com/image1.jpg", state.paragraphs[1].words[0].segmentText)
|
assertEquals("https://example.com/image1.jpg", state.paragraphs[1].words[0].segmentText)
|
||||||
Assert.assertEquals("https://example.com/image2.png", state.paragraphs[1].words[1].segmentText)
|
assertEquals("https://example.com/image2.png", state.paragraphs[1].words[1].segmentText)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -125,13 +124,13 @@ class GalleryParserTest {
|
|||||||
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
||||||
|
|
||||||
// Should have 2 image segments (image + video URLs)
|
// Should have 2 image segments (image + video URLs)
|
||||||
Assert.assertEquals(2, state.paragraphs.size)
|
assertEquals(2, state.paragraphs.size)
|
||||||
|
|
||||||
// Should render as gallery (1 gallery with 2 images)
|
// Should render as gallery (1 gallery with 2 images)
|
||||||
Assert.assertTrue("Should render 1 gallery", state.paragraphs[1] is ImageGalleryParagraph)
|
assertTrue("Should render 1 gallery", state.paragraphs[1] is ImageGalleryParagraph)
|
||||||
Assert.assertEquals("Gallery should contain 2 images", 2, state.paragraphs[1].words.size)
|
assertEquals(2, state.paragraphs[1].words.size, "Gallery should contain 2 images")
|
||||||
Assert.assertEquals("https://example.com/image1.jpg", state.paragraphs[1].words[0].segmentText)
|
assertEquals("https://example.com/image1.jpg", state.paragraphs[1].words[0].segmentText)
|
||||||
Assert.assertEquals("https://example.com/image2.png", state.paragraphs[1].words[1].segmentText)
|
assertEquals("https://example.com/image2.png", state.paragraphs[1].words[1].segmentText)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -142,9 +141,9 @@ class GalleryParserTest {
|
|||||||
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
||||||
|
|
||||||
// Should render individually (not as gallery)
|
// Should render individually (not as gallery)
|
||||||
Assert.assertTrue("Should render 1 individual image", state.paragraphs[1] !is ImageGalleryParagraph)
|
assertTrue("Should render 1 individual image", state.paragraphs[1] !is ImageGalleryParagraph)
|
||||||
Assert.assertTrue("Should not render as gallery", state.paragraphs[0] !is ImageGalleryParagraph)
|
assertTrue("Should not render as gallery", state.paragraphs[0] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals("https://example.com/image.jpg", state.paragraphs[1].words[0].segmentText)
|
assertEquals("https://example.com/image.jpg", state.paragraphs[1].words[0].segmentText)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -154,10 +153,10 @@ class GalleryParserTest {
|
|||||||
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
||||||
|
|
||||||
// Should render individually (not as gallery)
|
// Should render individually (not as gallery)
|
||||||
Assert.assertEquals("I played The Typing of the Dead a lot when I was younger, and now I just found out that there's a new take on it: The Last Sentence. Tempted!", state.paragraphs[0].words[0].segmentText)
|
assertEquals("I played The Typing of the Dead a lot when I was younger, and now I just found out that there's a new take on it: The Last Sentence. Tempted!", state.paragraphs[0].words[0].segmentText)
|
||||||
Assert.assertTrue("Should render as gallery", state.paragraphs[1] is ImageGalleryParagraph)
|
assertTrue("Should render as gallery", state.paragraphs[1] is ImageGalleryParagraph)
|
||||||
Assert.assertEquals("https://relay.dergigi.com/d6a3e33b101fe219ef251ac6261c10392c2af9918c3c252d4c202016b0b4ec83.jpg", state.paragraphs[1].words[0].segmentText)
|
assertEquals("https://relay.dergigi.com/d6a3e33b101fe219ef251ac6261c10392c2af9918c3c252d4c202016b0b4ec83.jpg", state.paragraphs[1].words[0].segmentText)
|
||||||
Assert.assertEquals("https://relay.dergigi.com/d60c9c562912573f214c2b1958cc20bf8913cd718d2ed9e020621e3e3120634b.jpg", state.paragraphs[1].words[1].segmentText)
|
assertEquals("https://relay.dergigi.com/d60c9c562912573f214c2b1958cc20bf8913cd718d2ed9e020621e3e3120634b.jpg", state.paragraphs[1].words[1].segmentText)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -171,23 +170,23 @@ class GalleryParserTest {
|
|||||||
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
||||||
|
|
||||||
// Should have 4 paragraphs (text, image, video, hashtags)
|
// Should have 4 paragraphs (text, image, video, hashtags)
|
||||||
Assert.assertEquals(4, state.paragraphs.size)
|
assertEquals(4, state.paragraphs.size)
|
||||||
|
|
||||||
// First paragraph is text
|
// First paragraph is text
|
||||||
Assert.assertTrue(state.paragraphs[0] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[0] !is ImageGalleryParagraph)
|
||||||
|
|
||||||
// Second paragraph is image (rendered individually, not as gallery)
|
// Second paragraph is image (rendered individually, not as gallery)
|
||||||
Assert.assertTrue(state.paragraphs[1] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[1] !is ImageGalleryParagraph)
|
||||||
Assert.assertTrue(state.paragraphs[1].words[0] is ImageSegment)
|
assertTrue(state.paragraphs[1].words[0] is ImageSegment)
|
||||||
Assert.assertEquals("https://image.tmdb.org/t/p/original/1r7iOhXSbbuUTORNEUOvCUkQ86K.jpg", state.paragraphs[1].words[0].segmentText)
|
assertEquals("https://image.tmdb.org/t/p/original/1r7iOhXSbbuUTORNEUOvCUkQ86K.jpg", state.paragraphs[1].words[0].segmentText)
|
||||||
|
|
||||||
// Third paragraph is video (rendered individually)
|
// Third paragraph is video (rendered individually)
|
||||||
Assert.assertTrue(state.paragraphs[2] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[2] !is ImageGalleryParagraph)
|
||||||
Assert.assertTrue(state.paragraphs[2].words[0] is VideoSegment)
|
assertTrue(state.paragraphs[2].words[0] is VideoSegment)
|
||||||
Assert.assertEquals("https://archive.org/download/the-crow-1994_20231024/The%20Crow%201994.rar/The%20Crow%201994.1080p.BluRay.x264%20.%20NVEE%2FThe%20Crow%201994.1080p.BluRay.x264%20.%20NVEE.mp4", state.paragraphs[2].words[0].segmentText)
|
assertEquals("https://archive.org/download/the-crow-1994_20231024/The%20Crow%201994.rar/The%20Crow%201994.1080p.BluRay.x264%20.%20NVEE%2FThe%20Crow%201994.1080p.BluRay.x264%20.%20NVEE.mp4", state.paragraphs[2].words[0].segmentText)
|
||||||
|
|
||||||
// Fourth paragraph is hashtags
|
// Fourth paragraph is hashtags
|
||||||
Assert.assertTrue(state.paragraphs[3] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[3] !is ImageGalleryParagraph)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -201,25 +200,25 @@ class GalleryParserTest {
|
|||||||
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
val state = RichTextParser().parseText(text, EmptyTagList, null)
|
||||||
|
|
||||||
// Should have 4 paragraphs (text, image, video, hashtags)
|
// Should have 4 paragraphs (text, image, video, hashtags)
|
||||||
Assert.assertEquals(4, state.paragraphs.size)
|
assertEquals(4, state.paragraphs.size)
|
||||||
|
|
||||||
// First paragraph is text
|
// First paragraph is text
|
||||||
Assert.assertTrue(state.paragraphs[0] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[0] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals("Desperado (1995)", state.paragraphs[0].words[0].segmentText)
|
assertEquals("Desperado (1995)", state.paragraphs[0].words[0].segmentText)
|
||||||
|
|
||||||
// Second paragraph is image (rendered individually, not as gallery)
|
// Second paragraph is image (rendered individually, not as gallery)
|
||||||
Assert.assertTrue(state.paragraphs[1] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[1] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals(1, state.paragraphs[1].words.size)
|
assertEquals(1, state.paragraphs[1].words.size)
|
||||||
Assert.assertTrue(state.paragraphs[1].words[0] is ImageSegment)
|
assertTrue(state.paragraphs[1].words[0] is ImageSegment)
|
||||||
Assert.assertEquals("https://media.themoviedb.org/t/p/w440_and_h660_face/e3gwpBeXpvGZsxUya9zNym5QXrw.jpg", state.paragraphs[1].words[0].segmentText)
|
assertEquals("https://media.themoviedb.org/t/p/w440_and_h660_face/e3gwpBeXpvGZsxUya9zNym5QXrw.jpg", state.paragraphs[1].words[0].segmentText)
|
||||||
|
|
||||||
// Third paragraph is video (rendered individually)
|
// Third paragraph is video (rendered individually)
|
||||||
Assert.assertTrue(state.paragraphs[2] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[2] !is ImageGalleryParagraph)
|
||||||
Assert.assertEquals(1, state.paragraphs[2].words.size)
|
assertEquals(1, state.paragraphs[2].words.size)
|
||||||
Assert.assertTrue(state.paragraphs[2].words[0] is VideoSegment)
|
assertTrue(state.paragraphs[2].words[0] is VideoSegment)
|
||||||
Assert.assertEquals("https://archive.org/download/desperado.-1995.1080p.-blu-ray.x-264.-yify/Desperado.1995.1080p.BluRay.x264.YIFY.mp4", state.paragraphs[2].words[0].segmentText)
|
assertEquals("https://archive.org/download/desperado.-1995.1080p.-blu-ray.x-264.-yify/Desperado.1995.1080p.BluRay.x264.YIFY.mp4", state.paragraphs[2].words[0].segmentText)
|
||||||
|
|
||||||
// Fourth paragraph is hashtags
|
// Fourth paragraph is hashtags
|
||||||
Assert.assertTrue(state.paragraphs[3] !is ImageGalleryParagraph)
|
assertTrue(state.paragraphs[3] !is ImageGalleryParagraph)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+30
-31
@@ -20,14 +20,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.commons.richtext
|
package com.vitorpamplona.amethyst.commons.richtext
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
||||||
import com.vitorpamplona.amethyst.commons.model.EmptyTagList
|
import com.vitorpamplona.amethyst.commons.model.EmptyTagList
|
||||||
import com.vitorpamplona.amethyst.commons.model.ImmutableListOfLists
|
import com.vitorpamplona.amethyst.commons.model.ImmutableListOfLists
|
||||||
import junit.framework.TestCase.assertEquals
|
import junit.framework.TestCase
|
||||||
import org.junit.Test
|
import kotlin.test.Test
|
||||||
import org.junit.runner.RunWith
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class RichTextParserTest {
|
class RichTextParserTest {
|
||||||
private val textToParse =
|
private val textToParse =
|
||||||
"""
|
"""
|
||||||
@@ -689,7 +688,7 @@ class RichTextParserTest {
|
|||||||
val state =
|
val state =
|
||||||
RichTextParser()
|
RichTextParser()
|
||||||
.parseText(textToParse, EmptyTagList, null)
|
.parseText(textToParse, EmptyTagList, null)
|
||||||
assertEquals(
|
TestCase.assertEquals(
|
||||||
"relay.shitforce.one, relayable.org, universe.nostrich.land, nos.lol, universe.nostrich.land?lang=zh, universe.nostrich.land?lang=en, relay.damus.io, relay.nostr.wirednet.jp, offchain.pub, nostr.rocks, relay.wellorder.net, nostr.oxtr.dev, universe.nostrich.land?lang=ja, relay.mostr.pub, nostr.bitcoiner.social, Nostr-Check.com, MR.Rabbit, Ancap.su, ⚡\uFE0Fsatscoinsv@getalby.com, miceliomad@miceliomad.github.io/nostr/, zapper.lol, smies.me, baller.hodl",
|
"relay.shitforce.one, relayable.org, universe.nostrich.land, nos.lol, universe.nostrich.land?lang=zh, universe.nostrich.land?lang=en, relay.damus.io, relay.nostr.wirednet.jp, offchain.pub, nostr.rocks, relay.wellorder.net, nostr.oxtr.dev, universe.nostrich.land?lang=ja, relay.mostr.pub, nostr.bitcoiner.social, Nostr-Check.com, MR.Rabbit, Ancap.su, ⚡\uFE0Fsatscoinsv@getalby.com, miceliomad@miceliomad.github.io/nostr/, zapper.lol, smies.me, baller.hodl",
|
||||||
state.urlSet.joinToString(", "),
|
state.urlSet.joinToString(", "),
|
||||||
)
|
)
|
||||||
@@ -4021,16 +4020,16 @@ class RichTextParserTest {
|
|||||||
.map { it.words }
|
.map { it.words }
|
||||||
.flatten()
|
.flatten()
|
||||||
.forEachIndexed { index, seg ->
|
.forEachIndexed { index, seg ->
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
expectedResult[index],
|
expectedResult[index],
|
||||||
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
org.junit.Assert.assertTrue(state.imagesForPager.isEmpty())
|
assertTrue(state.imagesForPager.isEmpty())
|
||||||
org.junit.Assert.assertTrue(state.imageList.isEmpty())
|
assertTrue(state.imageList.isEmpty())
|
||||||
org.junit.Assert.assertTrue(state.customEmoji.isEmpty())
|
assertTrue(state.customEmoji.isEmpty())
|
||||||
org.junit.Assert.assertEquals(651, state.paragraphs.size)
|
assertEquals(651, state.paragraphs.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -4038,11 +4037,11 @@ class RichTextParserTest {
|
|||||||
val state =
|
val state =
|
||||||
RichTextParser()
|
RichTextParser()
|
||||||
.parseText("Hi, how are you doing? ", EmptyTagList, null)
|
.parseText("Hi, how are you doing? ", EmptyTagList, null)
|
||||||
org.junit.Assert.assertTrue(state.urlSet.isEmpty())
|
assertTrue(state.urlSet.isEmpty())
|
||||||
org.junit.Assert.assertTrue(state.imagesForPager.isEmpty())
|
assertTrue(state.imagesForPager.isEmpty())
|
||||||
org.junit.Assert.assertTrue(state.imageList.isEmpty())
|
assertTrue(state.imageList.isEmpty())
|
||||||
org.junit.Assert.assertTrue(state.customEmoji.isEmpty())
|
assertTrue(state.customEmoji.isEmpty())
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
"Hi, how are you doing?",
|
"Hi, how are you doing?",
|
||||||
state.paragraphs
|
state.paragraphs
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
@@ -4056,11 +4055,11 @@ class RichTextParserTest {
|
|||||||
fun testShortNewLinesTextToParse() {
|
fun testShortNewLinesTextToParse() {
|
||||||
val state =
|
val state =
|
||||||
RichTextParser().parseText("\nHi, \nhow\n\n\n are you doing? \n", EmptyTagList, null)
|
RichTextParser().parseText("\nHi, \nhow\n\n\n are you doing? \n", EmptyTagList, null)
|
||||||
org.junit.Assert.assertTrue(state.urlSet.isEmpty())
|
assertTrue(state.urlSet.isEmpty())
|
||||||
org.junit.Assert.assertTrue(state.imagesForPager.isEmpty())
|
assertTrue(state.imagesForPager.isEmpty())
|
||||||
org.junit.Assert.assertTrue(state.imageList.isEmpty())
|
assertTrue(state.imageList.isEmpty())
|
||||||
org.junit.Assert.assertTrue(state.customEmoji.isEmpty())
|
assertTrue(state.customEmoji.isEmpty())
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
"\nHi,\nhow\n\n\n are you doing?\n",
|
"\nHi,\nhow\n\n\n are you doing?\n",
|
||||||
state.paragraphs.joinToString("\n") { it.words.joinToString(" ") { it.segmentText } },
|
state.paragraphs.joinToString("\n") { it.words.joinToString(" ") { it.segmentText } },
|
||||||
)
|
)
|
||||||
@@ -4080,19 +4079,19 @@ class RichTextParserTest {
|
|||||||
val state =
|
val state =
|
||||||
RichTextParser()
|
RichTextParser()
|
||||||
.parseText(text, EmptyTagList, null)
|
.parseText(text, EmptyTagList, null)
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
"https://lnshort.it/live-stream-embeds/",
|
"https://lnshort.it/live-stream-embeds/",
|
||||||
state.urlSet.firstOrNull(),
|
state.urlSet.firstOrNull(),
|
||||||
)
|
)
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
"https://nostr.build/i/fd53fcf5ad950fbe45127e4bcee1b59e8301d41de6beee211f45e344db214e8a.jpg",
|
"https://nostr.build/i/fd53fcf5ad950fbe45127e4bcee1b59e8301d41de6beee211f45e344db214e8a.jpg",
|
||||||
state.imagesForPager.keys.firstOrNull(),
|
state.imagesForPager.keys.firstOrNull(),
|
||||||
)
|
)
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
"https://nostr.build/i/fd53fcf5ad950fbe45127e4bcee1b59e8301d41de6beee211f45e344db214e8a.jpg",
|
"https://nostr.build/i/fd53fcf5ad950fbe45127e4bcee1b59e8301d41de6beee211f45e344db214e8a.jpg",
|
||||||
state.imageList.firstOrNull()?.url,
|
state.imageList.firstOrNull()?.url,
|
||||||
)
|
)
|
||||||
org.junit.Assert.assertTrue(state.customEmoji.isEmpty())
|
assertTrue(state.customEmoji.isEmpty())
|
||||||
|
|
||||||
printStateForDebug(state)
|
printStateForDebug(state)
|
||||||
|
|
||||||
@@ -4142,7 +4141,7 @@ class RichTextParserTest {
|
|||||||
.map { it.words }
|
.map { it.words }
|
||||||
.flatten()
|
.flatten()
|
||||||
.forEachIndexed { index, seg ->
|
.forEachIndexed { index, seg ->
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
expectedResult[index],
|
expectedResult[index],
|
||||||
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
||||||
)
|
)
|
||||||
@@ -4175,7 +4174,7 @@ class RichTextParserTest {
|
|||||||
.map { it.words }
|
.map { it.words }
|
||||||
.flatten()
|
.flatten()
|
||||||
.forEachIndexed { index, seg ->
|
.forEachIndexed { index, seg ->
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
expectedResult[index],
|
expectedResult[index],
|
||||||
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
||||||
)
|
)
|
||||||
@@ -4207,7 +4206,7 @@ class RichTextParserTest {
|
|||||||
.map { it.words }
|
.map { it.words }
|
||||||
.flatten()
|
.flatten()
|
||||||
.forEachIndexed { index, seg ->
|
.forEachIndexed { index, seg ->
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
expectedResult[index],
|
expectedResult[index],
|
||||||
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
||||||
)
|
)
|
||||||
@@ -4239,7 +4238,7 @@ class RichTextParserTest {
|
|||||||
.map { it.words }
|
.map { it.words }
|
||||||
.flatten()
|
.flatten()
|
||||||
.forEachIndexed { index, seg ->
|
.forEachIndexed { index, seg ->
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
expectedResult[index],
|
expectedResult[index],
|
||||||
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
||||||
)
|
)
|
||||||
@@ -4270,7 +4269,7 @@ class RichTextParserTest {
|
|||||||
.map { it.words }
|
.map { it.words }
|
||||||
.flatten()
|
.flatten()
|
||||||
.forEachIndexed { index, seg ->
|
.forEachIndexed { index, seg ->
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
expectedResult[index],
|
expectedResult[index],
|
||||||
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
||||||
)
|
)
|
||||||
@@ -4308,7 +4307,7 @@ class RichTextParserTest {
|
|||||||
.map { it.words }
|
.map { it.words }
|
||||||
.flatten()
|
.flatten()
|
||||||
.forEachIndexed { index, seg ->
|
.forEachIndexed { index, seg ->
|
||||||
org.junit.Assert.assertEquals(
|
assertEquals(
|
||||||
expectedResult[index],
|
expectedResult[index],
|
||||||
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
"${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})",
|
||||||
)
|
)
|
||||||
Reference in New Issue
Block a user