fix: parse verify credentials user id
This commit is contained in:
@@ -107,6 +107,24 @@ describe('TwitterClient getCurrentUser', () => {
|
||||
expect(mockFetch).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('reads top-level id_str from verify_credentials responses', async () => {
|
||||
mockFetch.mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
json: async () => ({
|
||||
id_str: '12345',
|
||||
screen_name: 'tester',
|
||||
name: 'Test User',
|
||||
}),
|
||||
});
|
||||
|
||||
const client = new TwitterClient({ relayBaseUrl: testRelayBaseUrl });
|
||||
const result = await client.getCurrentUser();
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.user).toEqual({ id: '12345', username: 'tester', name: 'Test User' });
|
||||
});
|
||||
|
||||
it('continues on fetch errors and still succeeds via later API endpoint', async () => {
|
||||
mockFetch
|
||||
.mockRejectedValueOnce(new Error('boom'))
|
||||
|
||||
Reference in New Issue
Block a user