This commit is contained in:
@@ -9,6 +9,7 @@ describe('replies command', () => {
|
||||
({
|
||||
resolveTimeoutFromOptions: () => undefined,
|
||||
resolveQuoteDepthFromOptions: () => 1,
|
||||
resolveProfileNameFromOptions: () => undefined,
|
||||
extractTweetId: (input: string) => input,
|
||||
resolveRelayBaseUrlFromOptions: () => 'https://relay.example',
|
||||
p: () => '',
|
||||
@@ -74,6 +75,38 @@ describe('replies command', () => {
|
||||
errorSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it('passes profileName to TwitterClient', async () => {
|
||||
const program = new Command();
|
||||
registerReadCommands(program, {
|
||||
...createMockContext(),
|
||||
resolveProfileNameFromOptions: () => 'work',
|
||||
});
|
||||
|
||||
const getTweetSpy = vi.spyOn(TwitterClient.prototype, 'getTweet').mockImplementation(async function () {
|
||||
const headers = (this as unknown as { getHeaders: () => Record<string, string> }).getHeaders();
|
||||
expect(headers).toEqual({ 'x-profile-name': 'work' });
|
||||
return {
|
||||
success: true,
|
||||
tweet: {
|
||||
id: '123',
|
||||
text: 'hello',
|
||||
author: { username: 'tester', name: 'Tester' },
|
||||
createdAt: '2024-01-01T00:00:00Z',
|
||||
url: 'https://x.com/tester/status/123',
|
||||
},
|
||||
};
|
||||
});
|
||||
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
||||
|
||||
try {
|
||||
await program.parseAsync(['node', 'bird', 'read', '123', '--json']);
|
||||
expect(getTweetSpy).toHaveBeenCalledTimes(1);
|
||||
} finally {
|
||||
getTweetSpy.mockRestore();
|
||||
logSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('thread command', () => {
|
||||
@@ -81,6 +114,7 @@ describe('thread command', () => {
|
||||
({
|
||||
resolveTimeoutFromOptions: () => undefined,
|
||||
resolveQuoteDepthFromOptions: () => 1,
|
||||
resolveProfileNameFromOptions: () => undefined,
|
||||
extractTweetId: (input: string) => input,
|
||||
resolveRelayBaseUrlFromOptions: () => 'https://relay.example',
|
||||
p: () => '',
|
||||
|
||||
Reference in New Issue
Block a user