import { describe, expect, it } from 'vitest';
import { generateNextMetadata, renderMetaTagsHtml } from '../../seo/meta-tags.js';
const BASE = {
    title: 'Hello',
    description: 'A page',
    url: 'https://example.com/hello',
    siteName: 'Acme',
    canonical: 'https://example.com/hello',
};
describe('meta-tags: metadataBase + hreflang alternates', () => {
    it('sets metadataBase as a URL in the Next metadata object', () => {
        const meta = generateNextMetadata({ ...BASE, metadataBase: 'https://example.com' });
        expect(meta.metadataBase).toBeInstanceOf(URL);
        expect(meta.metadataBase.href).toBe('https://example.com/');
    });
    it('ignores an unparseable metadataBase without throwing', () => {
        const meta = generateNextMetadata({ ...BASE, metadataBase: 'not a url' });
        expect(meta.metadataBase).toBeUndefined();
    });
    it('maps hreflang alternates to alternates.languages alongside canonical', () => {
        const meta = generateNextMetadata({
            ...BASE,
            alternates: [
                { hreflang: 'en', href: 'https://example.com/hello' },
                { hreflang: 'fr', href: 'https://example.com/fr/bonjour' },
                { hreflang: 'x-default', href: 'https://example.com/hello' },
            ],
        });
        expect(meta.alternates?.canonical).toBe('https://example.com/hello');
        expect(meta.alternates?.languages).toEqual({
            en: 'https://example.com/hello',
            fr: 'https://example.com/fr/bonjour',
            'x-default': 'https://example.com/hello',
        });
    });
    it('renders <link rel="alternate" hreflang> tags in HTML output', () => {
        const html = renderMetaTagsHtml({
            ...BASE,
            alternates: [
                { hreflang: 'en', href: 'https://example.com/hello' },
                { hreflang: 'fr', href: 'https://example.com/fr/bonjour' },
            ],
        });
        expect(html).toContain('<link rel="alternate" hreflang="en" href="https://example.com/hello" />');
        expect(html).toContain('<link rel="alternate" hreflang="fr" href="https://example.com/fr/bonjour" />');
    });
    it('emits no alternates block when none are supplied and no canonical', () => {
        const meta = generateNextMetadata({ ...BASE, canonical: undefined });
        expect(meta.alternates).toBeUndefined();
    });
});
//# sourceMappingURL=meta-tags-alternates.test.js.map