import { describe, expect, it } from 'vitest';
import { parseAvatarParts } from '../src/index.ts';

describe('parseAvatarParts', () => {
  it('годный облик — ok', () => {
    const v = { body: 1, eyes: 1, outfit: [1, 1], hair: [1, 1] };
    expect(parseAvatarParts(v)).toEqual({ ok: true, value: v });
  });

  it('ошибки схемы — по-русски, с путём к полю', () => {
    const r = parseAvatarParts({ body: 0, eyes: 1, outfit: [1], hair: [1, 1], x: 1 });
    expect(r.ok).toBe(false);
    if (r.ok) return;
    expect(r.errors).toEqual([expect.stringMatching(/^body: Слишком маленькое значение/), expect.stringMatching(/^outfit: /), '<корень>: Нераспознанный ключ: "x"']);
    expect(parseAvatarParts('строка')).toEqual({ ok: false, errors: ['<корень>: Неверный ввод: ожидалось object, получено string'] });
  });
});
