import { describe, it, expect } from 'vitest';
import { titleField, slugField, excerptField, richContentField, featuredImageField, tagsField, publishedDateField, authorField, quoteField, ctaField, seoFields, locationFields, geoFields, priceFields, } from '../../fields/presets.js';
describe('field presets', () => {
    it('titleField defaults to required text with placeholder', () => {
        const f = titleField();
        expect(f.title?.type).toBe('text');
        expect(f.title?.required).toBe(true);
        expect(f.title.admin?.placeholder).toBeTruthy();
    });
    it('titleField honors label and required overrides', () => {
        const f = titleField({ label: 'Headline', required: false });
        expect(f.title?.label).toBe('Headline');
        expect(f.title?.required).toBe(false);
    });
    it('slugField defaults to deriving from title and is unique', () => {
        const f = slugField();
        expect(f.slug?.type).toBe('slug');
        expect(f.slug.from).toBe('title');
        expect(f.slug?.unique).toBe(true);
        expect(f.slug?.required).toBe(true);
    });
    it('slugField allows custom source field', () => {
        const f = slugField({ from: 'question' });
        expect(f.slug.from).toBe('question');
    });
    it('excerptField has reasonable maxLength', () => {
        const f = excerptField();
        expect(f.excerpt.maxLength).toBe(280);
    });
    it('richContentField names default to "content" and accepts override', () => {
        const a = richContentField();
        expect(a.content?.type).toBe('richText');
        const b = richContentField({ name: 'body', label: 'Body' });
        expect(b.body?.type).toBe('richText');
        expect(b.body?.label).toBe('Body');
        expect(b.content).toBeUndefined();
    });
    it('featuredImageField restricts to web image types', () => {
        const f = featuredImageField();
        expect(f.featuredImage?.type).toBe('media');
        expect(f.featuredImage.accept).toEqual(expect.arrayContaining(['image/jpeg', 'image/png', 'image/webp']));
    });
    it('tagsField is an array with a single text child field', () => {
        const f = tagsField();
        expect(f.tags?.type).toBe('array');
        expect(f.tags.fields.tag?.type).toBe('text');
    });
    it('publishedDateField includes time', () => {
        const f = publishedDateField();
        expect(f.publishedDate.includeTime).toBe(true);
    });
    it('authorField adds a relationship when relationTo is supplied', () => {
        const a = authorField();
        expect(a.author).toBeUndefined();
        expect(a.authorName?.type).toBe('text');
        const b = authorField({ relationTo: 'team' });
        expect(b.author?.type).toBe('relationship');
        expect(b.author.relationTo).toBe('team');
    });
    it('quoteField allows naming the field', () => {
        const a = quoteField();
        expect(a.quote?.type).toBe('text');
        const b = quoteField({ name: 'pullQuote', label: 'Pull quote' });
        expect(b.pullQuote?.label).toBe('Pull quote');
    });
    it('ctaField returns label + url pair', () => {
        const f = ctaField();
        expect(f.ctaLabel?.type).toBe('text');
        expect(f.ctaUrl?.type).toBe('url');
    });
    it('seoFields renders the canonical SEO sidebar bundle', () => {
        const f = seoFields();
        for (const key of ['metaTitle', 'metaDescription', 'ogImage', 'canonical', 'noIndex']) {
            expect(f[key]).toBeDefined();
        }
        expect(f.metaTitle.admin?.position).toBe('sidebar');
    });
    it('locationFields includes address, phone, email, hours', () => {
        const f = locationFields();
        expect(f.address?.type).toBe('json');
        expect(f.phone?.type).toBe('text');
        expect(f.email?.type).toBe('email');
        expect(f.hours?.type).toBe('json');
    });
    it('geoFields clamps latitude/longitude ranges', () => {
        const f = geoFields();
        expect(f.latitude.min).toBe(-90);
        expect(f.latitude.max).toBe(90);
        expect(f.longitude.min).toBe(-180);
        expect(f.longitude.max).toBe(180);
    });
    it('priceFields default to USD', () => {
        const f = priceFields();
        expect(f.currency.defaultValue).toBe('USD');
        const eur = priceFields({ currency: 'EUR' });
        expect(eur.currency.defaultValue).toBe('EUR');
    });
});
//# sourceMappingURL=presets.test.js.map