Skip to content

Commit 66e34f9

Browse files
committed
fix(CommentThread): Replies not being parsed correctly
1 parent 0c2cdc1 commit 66e34f9

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/parser/classes/comments/CommentThread.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class CommentThread extends YTNode {
9090
if (!response.on_response_received_endpoints_memo)
9191
throw new InnertubeError('Unexpected response.', response);
9292

93-
this.replies = observe(response.on_response_received_endpoints_memo.getType(Comment).map((comment) => {
93+
this.replies = observe(response.on_response_received_endpoints_memo.getType(Comment, CommentView).map((comment) => {
9494
comment.setActions(this.#actions);
9595
return comment;
9696
}));

test/main.test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { createWriteStream, existsSync } from 'node:fs';
22
import { Innertube, Utils, YT, YTMusic, YTNodes } from '../bundle/node.cjs';
33

4+
jest.useRealTimers();
5+
46
describe('YouTube.js Tests', () => {
57
let innertube: Innertube;
68

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

101103
beforeAll(async () => {
102-
comments = await innertube.getComments('gmX-ceF-N1k');
104+
comments = await innertube.getComments('bUHZ2k9DYHY');
103105
expect(comments).toBeDefined();
104106
expect(comments.header).toBeDefined();
105107
expect(comments.contents).toBeDefined();
@@ -112,10 +114,20 @@ describe('YouTube.js Tests', () => {
112114
expect(incremental_continuation.contents.length).toBeGreaterThan(0);
113115
});
114116

115-
test('CommentThread#getReplies', async () => {
116-
let comment_thread = comments.contents.first();
117-
let loaded_comment_thread = await comment_thread.getReplies();
118-
expect(loaded_comment_thread.replies).toBeDefined();
117+
describe('CommentThread#getReplies', () => {
118+
let loaded_comment_thread: YTNodes.CommentThread;
119+
120+
beforeAll(async () => {
121+
let comment_thread = comments.contents.first();
122+
loaded_comment_thread = await comment_thread.getReplies();
123+
expect(loaded_comment_thread.replies).toBeDefined();
124+
});
125+
126+
test('CommentThread#getContinuation', async () => {
127+
const incremental_continuation = await loaded_comment_thread.getContinuation();
128+
expect(incremental_continuation.replies).toBeDefined();
129+
expect(incremental_continuation.replies?.length).toBeGreaterThan(0);
130+
});
119131
});
120132
});
121133

0 commit comments

Comments
 (0)