Improve seller account filtering
This commit is contained in:
1 parent
d819a0f1e6
commit
f4e8fdc42f
5 files changed
+178
-52
No files matched your search
@@ -242,6 +242,38 @@ describe('RedditApiClient', () => {
|
||||
});
|
||||
|
||||
describe('isSellerProfile', () => {
|
||||
it('returns true for a seller signal in the current post without fetching the profile', async () => {
|
||||
const get = vi.fn();
|
||||
vi.mocked(axios.create).mockReturnValue({ get } as any);
|
||||
const client2 = new RedditApiClient(getTestConfig(), logger);
|
||||
const post = {
|
||||
id: 'post-1', name: 't3_post-1', subreddit: 'test', author: 'testuser',
|
||||
title: 'Come and subscribe', selftext: 'My page is at https://onlyfans.com/example',
|
||||
url: 'https://reddit.com/post-1', permalink: '/r/test/post-1', thumbnail: '',
|
||||
is_self: true, created_utc: 1, over_18: true, spoiler: false,
|
||||
};
|
||||
|
||||
await expect(client2.isSellerProfile('testuser', ['onlyfans'], ['onlyfans.com'], post))
|
||||
.resolves.toBe(true);
|
||||
expect(get).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('detects seller signals in recent profile activity when the bio is clean', async () => {
|
||||
const get = vi.fn()
|
||||
.mockResolvedValueOnce({ data: { data: { subreddit: { public_description: 'Just me' } } } })
|
||||
.mockResolvedValueOnce({
|
||||
data: { data: { children: [{ data: { title: 'New content', subreddit: 'OnlyFansPromotions' } }] } },
|
||||
});
|
||||
vi.mocked(axios.create).mockReturnValue({ get } as any);
|
||||
const client2 = new RedditApiClient(getTestConfig(), logger);
|
||||
|
||||
await expect(client2.isSellerProfile('testuser', ['onlyfans'])).resolves.toBe(true);
|
||||
expect(get).toHaveBeenNthCalledWith(2, '/user/testuser/overview.json', {
|
||||
params: { limit: 25, raw_json: 1 },
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
|
||||
it('returns true when seller keyword matches', async () => {
|
||||
const mockResponse = {
|
||||
data: {
|
||||
|
||||
Reference in new issue
Block a user