From 1d3d7fa5c3ba41bd3f9366f0bda2432791048d79 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 28 Nov 2022 20:26:37 +0000 Subject: [PATCH] Add test for formatting. --- .../youtube/YoutubeCommentsExtractorTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java index 24c34b1d..6fa6148d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContains; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertGreater; import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.comments.CommentsInfoItem.UNKNOWN_REPLY_COUNT; @@ -344,4 +345,32 @@ public class YoutubeCommentsExtractorTest { assertGreater(300, firstComment.getReplyCount()); } } + + public static class FormattingTest { + + private final static String url = "https://www.youtube.com/watch?v=zYpyS2HaZHM"; + + private static YoutubeCommentsExtractor extractor; + + @BeforeAll + public static void setUp() throws Exception { + YoutubeTestsUtils.ensureStateless(); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "formatting")); + extractor = (YoutubeCommentsExtractor) YouTube + .getCommentsExtractor(url); + extractor.fetchPage(); + } + + @Test + public void testGetCommentsFormatting() throws IOException, ExtractionException { + final InfoItemsPage comments = extractor.getInitialPage(); + + DefaultTests.defaultTestListOfItems(YouTube, comments.getItems(), comments.getErrors()); + + final CommentsInfoItem firstComment = comments.getItems().get(0); + + assertContains("", firstComment.getCommentText()); + assertContains("", firstComment.getCommentText()); + } + } }