Files
bird/tests/commands.lists.test.ts
yuta 45657a171e
CI / test (push) Successful in 10m5s
Publish npm package / publish (push) Successful in 9m53s
fix lists queries and authenticated list reading
2026-07-26 12:34:53 +09:00

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();
}
});
});