Improve tweet read reliability and test coverage

This commit is contained in:
Peter Steinberger
2025-11-28 08:07:44 +01:00
parent b2dc418860
commit 5889044d7b
5 changed files with 125 additions and 67 deletions
+1 -9
View File
@@ -1,16 +1,8 @@
import { describe, expect, it } from 'vitest';
import { extractTweetId } from '../src/lib/extract-tweet-id.js';
describe('CLI utilities', () => {
describe('extractTweetId', () => {
// Testing the URL extraction logic inline since it's a simple function
function extractTweetId(input: string): string {
const urlMatch = input.match(/(?:twitter\.com|x\.com)\/\w+\/status\/(\d+)/);
if (urlMatch) {
return urlMatch[1];
}
return input;
}
it('should extract ID from x.com URL', () => {
const url = 'https://x.com/steipete/status/1234567890123456789';
expect(extractTweetId(url)).toBe('1234567890123456789');