test(lists): improve test coverage and extract list ID parsing

- Extract extractListId to src/lib/extract-list-id.ts with proper tests
- Add json-full/includeRaw test for list timeline
- Add 404 retry tests for getOwnedLists and getListMemberships
- Add tests for skipping invalid list entries and missing owner handling
- Use shared TwitterClientPrivate type from fixtures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
Harper Reed
2026-01-03 16:55:29 +01:00
committed by Peter Steinberger
co-authored by Claude Opus 4.5
parent 7818440d65
commit 59e827e153
6 changed files with 370 additions and 35 deletions
+1 -22
View File
@@ -3,31 +3,10 @@
import type { Command } from 'commander';
import type { CliContext } from '../cli/shared.js';
import { extractListId } from '../lib/extract-list-id.js';
import type { TwitterList } from '../lib/twitter-client.js';
import { TwitterClient } from '../lib/twitter-client.js';
const NUMERIC_ID_REGEX = /^\d+$/;
const LIST_URL_REGEX = /(?:x\.com|twitter\.com)\/i\/lists\/(\d+)/i;
function extractListId(listIdOrUrl: string): string | null {
const trimmed = listIdOrUrl.trim();
// Numeric ID
if (NUMERIC_ID_REGEX.test(trimmed)) {
return trimmed;
}
// URL formats:
// https://x.com/i/lists/1234567890123456789
// https://twitter.com/i/lists/1234567890123456789
const urlMatch = trimmed.match(LIST_URL_REGEX);
if (urlMatch) {
return urlMatch[1];
}
return null;
}
function printLists(lists: TwitterList[], ctx: CliContext): void {
if (lists.length === 0) {
console.log('No lists found.');