import { describe, expect, it } from 'vitest';
import { parseEmbed } from '../embed.js';
describe('parseEmbed', () => {
    it('parses YouTube watch, short, youtu.be, and embed URLs to the no-cookie embed', () => {
        const expected = 'https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ';
        for (const url of [
            'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
            'https://youtube.com/watch?v=dQw4w9WgXcQ&t=10s',
            'https://youtu.be/dQw4w9WgXcQ',
            'https://www.youtube.com/shorts/dQw4w9WgXcQ',
            'https://www.youtube.com/embed/dQw4w9WgXcQ',
        ]) {
            const r = parseEmbed(url);
            expect(r, url).not.toBeNull();
            expect(r.provider).toBe('youtube');
            expect(r.embedUrl).toBe(expected);
        }
    });
    it('parses Vimeo URLs (bare, player, channel) to the player embed', () => {
        for (const url of [
            'https://vimeo.com/123456789',
            'https://player.vimeo.com/video/123456789',
            'https://vimeo.com/channels/staffpicks/123456789',
        ]) {
            const r = parseEmbed(url);
            expect(r, url).not.toBeNull();
            expect(r.provider).toBe('vimeo');
            expect(r.embedUrl).toBe('https://player.vimeo.com/video/123456789');
        }
    });
    it('parses Loom share + embed URLs to the loom embed', () => {
        const id = '0123456789abcdef0123456789abcdef';
        for (const url of [`https://www.loom.com/share/${id}`, `https://loom.com/embed/${id}`]) {
            const r = parseEmbed(url);
            expect(r, url).not.toBeNull();
            expect(r.provider).toBe('loom');
            expect(r.embedUrl).toBe(`https://www.loom.com/embed/${id}`);
        }
    });
    it('rejects disallowed providers, non-URLs, and unsafe schemes', () => {
        for (const bad of [
            '',
            'not a url',
            'javascript:alert(1)',
            'https://www.dailymotion.com/video/x123',
            'https://example.com/watch?v=abc',
            'https://vimeo.com/notanumber',
            'ftp://youtu.be/dQw4w9WgXcQ',
        ]) {
            expect(parseEmbed(bad), bad).toBeNull();
        }
    });
});
//# sourceMappingURL=embed.test.js.map