Add test for formatting.

This commit is contained in:
Kavin 2022-11-28 20:26:37 +00:00
parent 52fda37915
commit 1d3d7fa5c3
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
1 changed files with 29 additions and 0 deletions

View File

@ -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<CommentsInfoItem> comments = extractor.getInitialPage();
DefaultTests.defaultTestListOfItems(YouTube, comments.getItems(), comments.getErrors());
final CommentsInfoItem firstComment = comments.getItems().get(0);
assertContains("<s>", firstComment.getCommentText());
assertContains("<b>", firstComment.getCommentText());
}
}
}