"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const serializer_js_1 = require("./serializer.js");
function makeDNA(overrides) {
    return {
        id: 'test-uuid-1234',
        createdAt: '2025-01-01T00:00:00Z',
        updatedAt: '2025-01-01T00:00:00Z',
        status: 'active',
        identity: { name: 'Aylin', age: 24, nationality: 'TR', city: 'Istanbul', occupation: 'Model', personality_tags: ['fun', 'outgoing'], mbti: 'ENFP', backstory: 'A vibrant soul' },
        physicalMeasurements: { height_cm: 170, weight_kg: 55, body_type: 'slim', measurements: { bust: 90, waist: 60, hips: 90 } },
        skinMap: { base: '#F5D0A9', shadow: '#D4A574', highlight: '#FFE4C4' },
        faceAnatomy: { eye_shape: 'almond', eye_color: '#8B4513', eyebrow_shape: 'arched', nose_type: 'straight', lip_shape: 'full', cheekbones: 'high', jawline: 'soft', distinctive_marks: ['mole on left cheek'] },
        hairDNA: { style: 'wavy', length: 'long', texture: 'silky', root_color: '#3B2F2F', mid_color: '#5C4033', highlight_color: '#8B6914' },
        bodyBiometrics: { body_type_detail: 'hourglass', posture: 'upright', skin_texture: 'smooth' },
        profileView: { best_angle: 'left-45', signature_pose: 'hand-on-hip' },
        expressionMotion: { default_expression: 'smile', smile_type: 'warm', gaze_style: 'direct' },
        makeupStyle: { philosophy: 'natural', skin_finish: 'dewy', colors: { primary: '#C48793', secondary: '#E8B4B8', accent: '#8B0000' } },
        fashionStyle: { aesthetic: 'casual-chic', main_colors: ['#000000', '#FFFFFF', '#FF5733'], signature_pieces: ['jeans', 'blazer'] },
        technicalSettings: { camera_body: 'Canon R5', portrait_lens: '85mm f/1.4', full_body_lens: '35mm f/1.4', film_stock: 'Portra 400' },
        ...overrides,
    };
}
(0, vitest_1.describe)('serializeDNA', () => {
    (0, vitest_1.it)('should return a valid JSON string', () => {
        const dna = makeDNA();
        const json = (0, serializer_js_1.serializeDNA)(dna);
        (0, vitest_1.expect)(() => JSON.parse(json)).not.toThrow();
    });
    (0, vitest_1.it)('should preserve all 11 components', () => {
        const dna = makeDNA();
        const json = (0, serializer_js_1.serializeDNA)(dna);
        const parsed = JSON.parse(json);
        (0, vitest_1.expect)(parsed.identity).toBeDefined();
        (0, vitest_1.expect)(parsed.physicalMeasurements).toBeDefined();
        (0, vitest_1.expect)(parsed.skinMap).toBeDefined();
        (0, vitest_1.expect)(parsed.faceAnatomy).toBeDefined();
        (0, vitest_1.expect)(parsed.hairDNA).toBeDefined();
        (0, vitest_1.expect)(parsed.bodyBiometrics).toBeDefined();
        (0, vitest_1.expect)(parsed.profileView).toBeDefined();
        (0, vitest_1.expect)(parsed.expressionMotion).toBeDefined();
        (0, vitest_1.expect)(parsed.makeupStyle).toBeDefined();
        (0, vitest_1.expect)(parsed.fashionStyle).toBeDefined();
        (0, vitest_1.expect)(parsed.technicalSettings).toBeDefined();
    });
    (0, vitest_1.it)('should preserve HEX color codes', () => {
        const dna = makeDNA();
        const json = (0, serializer_js_1.serializeDNA)(dna);
        const parsed = JSON.parse(json);
        (0, vitest_1.expect)(parsed.skinMap.base).toBe('#F5D0A9');
        (0, vitest_1.expect)(parsed.hairDNA.root_color).toBe('#3B2F2F');
        (0, vitest_1.expect)(parsed.makeupStyle.colors.accent).toBe('#8B0000');
        (0, vitest_1.expect)(parsed.fashionStyle.main_colors).toEqual(['#000000', '#FFFFFF', '#FF5733']);
    });
});
(0, vitest_1.describe)('parseDNA', () => {
    (0, vitest_1.it)('should parse a valid JSON string into CharacterDNA', () => {
        const dna = makeDNA();
        const json = JSON.stringify(dna);
        const result = (0, serializer_js_1.parseDNA)(json);
        (0, vitest_1.expect)(result).toEqual(dna);
    });
    (0, vitest_1.it)('should throw on invalid JSON', () => {
        (0, vitest_1.expect)(() => (0, serializer_js_1.parseDNA)('not json')).toThrow('Invalid JSON');
    });
    (0, vitest_1.it)('should throw on non-object JSON', () => {
        (0, vitest_1.expect)(() => (0, serializer_js_1.parseDNA)('"just a string"')).toThrow('Invalid CharacterDNA');
    });
    (0, vitest_1.it)('should throw when required fields are missing', () => {
        (0, vitest_1.expect)(() => (0, serializer_js_1.parseDNA)('{}')).toThrow('Invalid CharacterDNA');
    });
    (0, vitest_1.it)('should throw on invalid HEX color', () => {
        const dna = makeDNA();
        dna.skinMap.base = 'not-hex';
        const json = JSON.stringify(dna);
        (0, vitest_1.expect)(() => (0, serializer_js_1.parseDNA)(json)).toThrow('Invalid CharacterDNA');
    });
    (0, vitest_1.it)('should throw on invalid MBTI', () => {
        const dna = makeDNA();
        dna.identity.mbti = 'XXXX';
        const json = JSON.stringify(dna);
        (0, vitest_1.expect)(() => (0, serializer_js_1.parseDNA)(json)).toThrow('Invalid CharacterDNA');
    });
    (0, vitest_1.it)('should throw on invalid status', () => {
        const dna = makeDNA();
        dna.status = 'unknown';
        const json = JSON.stringify(dna);
        (0, vitest_1.expect)(() => (0, serializer_js_1.parseDNA)(json)).toThrow('Invalid CharacterDNA');
    });
});
(0, vitest_1.describe)('round-trip consistency', () => {
    (0, vitest_1.it)('serialize(parse(serialize(dna))) === serialize(dna)', () => {
        const dna = makeDNA();
        const first = (0, serializer_js_1.serializeDNA)(dna);
        const reparsed = (0, serializer_js_1.parseDNA)(first);
        const second = (0, serializer_js_1.serializeDNA)(reparsed);
        (0, vitest_1.expect)(second).toBe(first);
    });
    (0, vitest_1.it)('preserves all data through round-trip', () => {
        const dna = makeDNA();
        const roundTripped = (0, serializer_js_1.parseDNA)((0, serializer_js_1.serializeDNA)(dna));
        (0, vitest_1.expect)(roundTripped).toEqual(dna);
    });
    (0, vitest_1.it)('round-trip works with all status values', () => {
        for (const status of ['active', 'inactive', 'creating']) {
            const dna = makeDNA({ status });
            const result = (0, serializer_js_1.parseDNA)((0, serializer_js_1.serializeDNA)(dna));
            (0, vitest_1.expect)(result.status).toBe(status);
        }
    });
});
(0, vitest_1.describe)('cloneDNA', () => {
    (0, vitest_1.it)('should return an equal but independent copy', () => {
        const dna = makeDNA();
        const clone = (0, serializer_js_1.cloneDNA)(dna);
        (0, vitest_1.expect)(clone).toEqual(dna);
        // Verify independence
        clone.identity.name = 'Changed';
        (0, vitest_1.expect)(dna.identity.name).toBe('Aylin');
    });
    (0, vitest_1.it)('should deep clone arrays', () => {
        const dna = makeDNA();
        const clone = (0, serializer_js_1.cloneDNA)(dna);
        clone.fashionStyle.main_colors.push('#AABBCC');
        (0, vitest_1.expect)(dna.fashionStyle.main_colors).toHaveLength(3);
    });
    (0, vitest_1.it)('should deep clone nested objects', () => {
        const dna = makeDNA();
        const clone = (0, serializer_js_1.cloneDNA)(dna);
        clone.makeupStyle.colors.primary = '#000000';
        (0, vitest_1.expect)(dna.makeupStyle.colors.primary).toBe('#C48793');
    });
});
//# sourceMappingURL=serializer.test.js.map