@@ -13,14 +13,7 @@ describe('news command', () => {
|
||||
mockContext = {
|
||||
resolveTimeoutFromOptions: () => 30000,
|
||||
resolveQuoteDepthFromOptions: () => undefined,
|
||||
resolveCredentialsFromOptions: async () => ({
|
||||
cookies: {
|
||||
authToken: 'auth',
|
||||
ct0: 'ct0',
|
||||
cookieHeader: 'auth=auth; ct0=ct0',
|
||||
},
|
||||
warnings: [],
|
||||
}),
|
||||
resolveRelayBaseUrlFromOptions: () => 'https://relay.example',
|
||||
p: (type: string) => `[${type}] `,
|
||||
colors: {
|
||||
accent: (text: string) => text,
|
||||
@@ -128,31 +121,6 @@ describe('news command', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('requires both authToken and ct0 credentials', async () => {
|
||||
mockContext.resolveCredentialsFromOptions = async () => ({
|
||||
cookies: {
|
||||
authToken: '',
|
||||
ct0: '',
|
||||
cookieHeader: '',
|
||||
},
|
||||
warnings: [],
|
||||
});
|
||||
|
||||
registerNewsCommand(program, mockContext as CliContext);
|
||||
const exitSpy = vi.spyOn(process, 'exit').mockImplementation(((code?: number) => {
|
||||
throw new Error(`exit ${code}`);
|
||||
}) as never);
|
||||
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||
|
||||
try {
|
||||
await expect(program.parseAsync(['node', 'bird', 'news'])).rejects.toThrow('exit 1');
|
||||
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Missing required credentials'));
|
||||
} finally {
|
||||
exitSpy.mockRestore();
|
||||
errorSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it('limits related tweets to tweets-per-item in CLI output', async () => {
|
||||
registerNewsCommand(program, mockContext as CliContext);
|
||||
const getNewsSpy = vi.spyOn(TwitterClient.prototype, 'getNews').mockResolvedValue({
|
||||
|
||||
Reference in New Issue
Block a user