Skip to content

Commit

Permalink
fix(CommentThread): Replies not being parsed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT committed Apr 11, 2024
1 parent 0c2cdc1 commit 66e34f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/parser/classes/comments/CommentThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class CommentThread extends YTNode {
if (!response.on_response_received_endpoints_memo)
throw new InnertubeError('Unexpected response.', response);

this.replies = observe(response.on_response_received_endpoints_memo.getType(Comment).map((comment) => {
this.replies = observe(response.on_response_received_endpoints_memo.getType(Comment, CommentView).map((comment) => {
comment.setActions(this.#actions);
return comment;
}));
Expand Down
22 changes: 17 additions & 5 deletions test/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createWriteStream, existsSync } from 'node:fs';
import { Innertube, Utils, YT, YTMusic, YTNodes } from '../bundle/node.cjs';

jest.useRealTimers();

describe('YouTube.js Tests', () => {
let innertube: Innertube;

Expand Down Expand Up @@ -99,7 +101,7 @@ describe('YouTube.js Tests', () => {
let comments: YT.Comments;

beforeAll(async () => {
comments = await innertube.getComments('gmX-ceF-N1k');
comments = await innertube.getComments('bUHZ2k9DYHY');
expect(comments).toBeDefined();
expect(comments.header).toBeDefined();
expect(comments.contents).toBeDefined();
Expand All @@ -112,10 +114,20 @@ describe('YouTube.js Tests', () => {
expect(incremental_continuation.contents.length).toBeGreaterThan(0);
});

test('CommentThread#getReplies', async () => {
let comment_thread = comments.contents.first();
let loaded_comment_thread = await comment_thread.getReplies();
expect(loaded_comment_thread.replies).toBeDefined();
describe('CommentThread#getReplies', () => {
let loaded_comment_thread: YTNodes.CommentThread;

beforeAll(async () => {
let comment_thread = comments.contents.first();
loaded_comment_thread = await comment_thread.getReplies();
expect(loaded_comment_thread.replies).toBeDefined();
});

test('CommentThread#getContinuation', async () => {
const incremental_continuation = await loaded_comment_thread.getContinuation();
expect(incremental_continuation.replies).toBeDefined();
expect(incremental_continuation.replies?.length).toBeGreaterThan(0);
});
});
});

Expand Down

0 comments on commit 66e34f9

Please sign in to comment.