This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add method for listing posts in a hashtag (#38)
- Loading branch information
Showing
6 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { | ||
CountOffsetParams, | ||
ListRequestParams, | ||
ListResponseData, | ||
} from './request'; | ||
import { Post } from './post'; | ||
|
||
export interface ListPostsInHashtagRequest extends ListRequestParams, CountOffsetParams { | ||
/** The ID of the hashtag */ | ||
ch_id: string; | ||
|
||
/** ??? - set to 0 */ | ||
query_type: number; | ||
|
||
/** ??? - set to 5 */ | ||
type: number; | ||
} | ||
|
||
export interface ListPostsInHashtagResponse extends ListResponseData, CountOffsetParams { | ||
/** A list of posts containing the hashtag */ | ||
aweme_list: Post[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import MockAdapter from 'axios-mock-adapter'; | ||
import { assert } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
|
||
import TikTokAPI, { ListPostsInHashtagRequest, ListPostsInHashtagResponse } from '../src'; | ||
import { | ||
loadTestData, | ||
mockConfig, | ||
mockParams, | ||
} from './util'; | ||
|
||
describe('#listPostsInHashtag()', () => { | ||
it('a successful response should match the interface', async () => { | ||
const api = new TikTokAPI(mockParams, mockConfig); | ||
const mock = new MockAdapter(api.request); | ||
mock | ||
.onGet(new RegExp('aweme/v1/challenge/aweme/\?.*')) | ||
.reply(200, loadTestData('listPostsInHashtag.json'), {}); | ||
|
||
const res = await api.listPostsInHashtag({ ch_id: '1000' } as ListPostsInHashtagRequest); | ||
const expected: ListPostsInHashtagResponse = { | ||
extra: { | ||
now: 1000000000000, | ||
}, | ||
aweme_list: [], | ||
cursor: 20, | ||
has_more: 1, | ||
status_code: 0, | ||
}; | ||
assert.deepStrictEqual(res.data, expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extra": { | ||
"now": 1000000000000 | ||
}, | ||
"aweme_list": [], | ||
"cursor": 20, | ||
"has_more": 1, | ||
"status_code": 0 | ||
} |
how to implement it ?