36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { Command } from 'commander';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import type { CliContext } from '../src/cli/shared.js';
|
|
import { registerListsCommand } from '../src/commands/lists.js';
|
|
import { TwitterClient } from '../src/lib/twitter-client.js';
|
|
|
|
describe('lists command', () => {
|
|
it('uses the authenticated Lists page by default', async () => {
|
|
const program = new Command();
|
|
const ctx = {
|
|
resolveTimeoutFromOptions: () => undefined,
|
|
resolveRelayBaseUrlFromOptions: () => 'https://relay.example',
|
|
resolveProfileNameFromOptions: () => undefined,
|
|
p: () => '',
|
|
colors: { muted: (value: string) => value, accent: (value: string) => value },
|
|
getOutput: () => 'plain',
|
|
} as unknown as CliContext;
|
|
const listsSpy = vi.spyOn(TwitterClient.prototype, 'getLists').mockResolvedValue({
|
|
success: true,
|
|
lists: [],
|
|
});
|
|
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
|
|
try {
|
|
registerListsCommand(program, ctx);
|
|
await program.parseAsync(['node', 'bird', 'lists', '--count', '25']);
|
|
|
|
expect(listsSpy).toHaveBeenCalledWith(25);
|
|
expect(logSpy).toHaveBeenCalledWith('No lists found.');
|
|
} finally {
|
|
listsSpy.mockRestore();
|
|
logSpy.mockRestore();
|
|
}
|
|
});
|
|
});
|