import { describe, it, expect } from 'vitest';
import { validateStyles, stylesToClasses, STYLE_GROUPS } from '../src/lib/style-presets';

describe('style presets', () => {
  it('accetta chiavi e valori in whitelist', () => {
    const r = validateStyles({ size: 'l', color: 'accent', align: 'center' });
    expect(r).toEqual({ ok: true, styles: { size: 'l', color: 'accent', align: 'center' } });
  });

  it('rifiuta gruppo sconosciuto e valore fuori lista', () => {
    expect(validateStyles({ font: 'comic' }).ok).toBe(false);
    expect(validateStyles({ size: 'xxl' }).ok).toBe(false);
    expect(validateStyles('non-oggetto').ok).toBe(false);
  });

  it('mappa stili in classi cs-*', () => {
    expect(stylesToClasses({ size: 's', weight: 'bold' })).toBe('cs-size-s cs-weight-bold');
    expect(stylesToClasses({})).toBe('');
  });

  it('espone i gruppi attesi', () => {
    expect(Object.keys(STYLE_GROUPS)).toEqual(['size', 'color', 'weight', 'style', 'align']);
  });
});
