Add account browsing simulation
This commit is contained in:
1 parent
e2d7dc4b82
commit
27012399ec
31 files changed
+1476
-28
No files matched your search
@@ -30,6 +30,32 @@ describe('RedditApiClient', () => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('getBrowsingComments', () => {
|
||||
it('returns typed comment identity and moderation fields without changing the text reader', async () => {
|
||||
const get = vi.fn().mockResolvedValue({
|
||||
data: [{ data: { children: [] } }, { data: { children: [{
|
||||
data: {
|
||||
name: 't1_comment', author: 'alice', subreddit: 'AskUK',
|
||||
permalink: '/r/AskUK/comments/post/topic/comment/', created_utc: 123,
|
||||
score: 7, body: 'A useful answer with enough detail', distinguished: null,
|
||||
},
|
||||
}] } }],
|
||||
});
|
||||
vi.mocked(axios.create).mockReturnValue({ get } as unknown as AxiosInstance);
|
||||
const client2 = new RedditApiClient(getTestConfig(), logger);
|
||||
|
||||
await expect(client2.getBrowsingComments('AskUK', 'post', 10)).resolves.toEqual([{
|
||||
fullname: 't1_comment', kind: 'comment', subreddit: 'AskUK', author: 'alice',
|
||||
permalink: '/r/AskUK/comments/post/topic/comment/', createdAt: 123_000,
|
||||
score: 7, text: 'A useful answer with enough detail', nsfw: false,
|
||||
parentPostId: 'post', distinguished: null, removed: false,
|
||||
}]);
|
||||
expect(get).toHaveBeenCalledWith('/r/AskUK/comments/post.json', {
|
||||
params: { limit: 10, depth: 1, sort: 'hot', raw_json: 1 }, headers: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('hasImage', () => {
|
||||
const validPostFactory = (overrides: Partial<RedditPost> = {}): RedditPost => ({
|
||||
id: 't3_test',
|
||||
|
||||
Reference in new issue
Block a user