Skip to content

Commit 1d3d7fa

Browse files
committed
Add test for formatting.
1 parent 52fda37 commit 1d3d7fa

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.junit.jupiter.api.Assertions.assertNotEquals;
66
import static org.junit.jupiter.api.Assertions.assertNotNull;
77
import static org.junit.jupiter.api.Assertions.assertTrue;
8+
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContains;
89
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertGreater;
910
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
1011
import static org.schabi.newpipe.extractor.comments.CommentsInfoItem.UNKNOWN_REPLY_COUNT;
@@ -344,4 +345,32 @@ public void testGetCommentsReplyCount() throws IOException, ExtractionException
344345
assertGreater(300, firstComment.getReplyCount());
345346
}
346347
}
348+
349+
public static class FormattingTest {
350+
351+
private final static String url = "https://www.youtube.com/watch?v=zYpyS2HaZHM";
352+
353+
private static YoutubeCommentsExtractor extractor;
354+
355+
@BeforeAll
356+
public static void setUp() throws Exception {
357+
YoutubeTestsUtils.ensureStateless();
358+
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "formatting"));
359+
extractor = (YoutubeCommentsExtractor) YouTube
360+
.getCommentsExtractor(url);
361+
extractor.fetchPage();
362+
}
363+
364+
@Test
365+
public void testGetCommentsFormatting() throws IOException, ExtractionException {
366+
final InfoItemsPage<CommentsInfoItem> comments = extractor.getInitialPage();
367+
368+
DefaultTests.defaultTestListOfItems(YouTube, comments.getItems(), comments.getErrors());
369+
370+
final CommentsInfoItem firstComment = comments.getItems().get(0);
371+
372+
assertContains("<s>", firstComment.getCommentText());
373+
assertContains("<b>", firstComment.getCommentText());
374+
}
375+
}
347376
}

0 commit comments

Comments
 (0)