import { describe, expect, it } from 'vitest'; import { classifyUrl } from './url-classifier.js'; describe('classifyUrl', () => { it('classifies YouTube watch URLs', () => { expect(classifyUrl('https://www.youtube.com/watch?v=dQw4w9WgXcQ')).toEqual({ contentType: 'youtube', confidence: 'high' }); }); it('classifies YouTube short URLs', () => { expect(classifyUrl('https://youtu.be/dQw4w9WgXcQ')).toEqual({ contentType: 'youtube', confidence: 'high' }); }); it('classifies YouTube shorts', () => { expect(classifyUrl('https://youtube.com/shorts/abc123')).toEqual({ contentType: 'youtube', confidence: 'high' }); }); it('classifies YouTube live URLs', () => { expect(classifyUrl('https://youtube.com/live/xyz789')).toEqual({ contentType: 'youtube', confidence: 'high' }); }); it('classifies Twitter status URLs', () => { expect(classifyUrl('https://twitter.com/user/status/12345')).toEqual({ contentType: 'tweet', confidence: 'high' }); }); it('classifies X.com status URLs', () => { expect(classifyUrl('https://x.com/user/status/12345')).toEqual({ contentType: 'tweet', confidence: 'high' }); }); it('classifies GitHub repo URLs', () => { expect(classifyUrl('https://github.com/owner/repo')).toEqual({ contentType: 'github', confidence: 'high' }); }); it('classifies GitHub repo URLs with trailing slash', () => { expect(classifyUrl('https://github.com/owner/repo/')).toEqual({ contentType: 'github', confidence: 'high' }); }); it('classifies Reddit URLs', () => { expect(classifyUrl('https://www.reddit.com/r/typescript/comments/abc')).toEqual({ contentType: 'reddit', confidence: 'high' }); }); it('classifies PDF URLs', () => { expect(classifyUrl('https://example.com/document.pdf')).toEqual({ contentType: 'pdf', confidence: 'high' }); }); it('classifies PDF URLs with query params', () => { expect(classifyUrl('https://example.com/doc.pdf?token=abc')).toEqual({ contentType: 'pdf', confidence: 'high' }); }); it('classifies generic article URLs', () => { expect(classifyUrl('https://blog.example.com/my-post')).toEqual({ contentType: 'article', confidence: 'low' }); }); it('classifies unknown URLs as article', () => { expect(classifyUrl('https://example.com')).toEqual({ contentType: 'article', confidence: 'low' }); }); });