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:
committed by
Peter Steinberger
co-authored by
Claude Opus 4.5
parent
7818440d65
commit
59e827e153
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { extractBookmarkFolderId } from '../src/lib/extract-bookmark-folder-id.js';
|
||||
import { extractListId } from '../src/lib/extract-list-id.js';
|
||||
import { extractTweetId } from '../src/lib/extract-tweet-id.js';
|
||||
|
||||
describe('CLI utilities', () => {
|
||||
@@ -56,4 +57,46 @@ describe('CLI utilities', () => {
|
||||
expect(extractBookmarkFolderId(url)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('extractListId', () => {
|
||||
it('should extract ID from x.com list URL', () => {
|
||||
const url = 'https://x.com/i/lists/1234567890123456789';
|
||||
expect(extractListId(url)).toBe('1234567890123456789');
|
||||
});
|
||||
|
||||
it('should extract ID from twitter.com list URL', () => {
|
||||
const url = 'https://twitter.com/i/lists/1234567890123456789';
|
||||
expect(extractListId(url)).toBe('1234567890123456789');
|
||||
});
|
||||
|
||||
it('should extract ID from URL with query params', () => {
|
||||
const url = 'https://x.com/i/lists/1234567890123456789?s=20';
|
||||
expect(extractListId(url)).toBe('1234567890123456789');
|
||||
});
|
||||
|
||||
it('should accept a numeric ID as-is', () => {
|
||||
const id = '1234567890123456789';
|
||||
expect(extractListId(id)).toBe('1234567890123456789');
|
||||
});
|
||||
|
||||
it('should return null for invalid values', () => {
|
||||
expect(extractListId('not-an-id')).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null for empty string', () => {
|
||||
expect(extractListId('')).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null for whitespace-only string', () => {
|
||||
expect(extractListId(' ')).toBeNull();
|
||||
});
|
||||
|
||||
it('should return null for short numeric IDs', () => {
|
||||
expect(extractListId('1234')).toBeNull();
|
||||
});
|
||||
|
||||
it('should trim whitespace from input', () => {
|
||||
expect(extractListId(' 1234567890123456789 ')).toBe('1234567890123456789');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user