import { describe, it, expect } from 'vitest'; import { checkStructure, checkStructureMailMessages } from '@/utils/checkStructure'; describe('checkStructure (blog)', () => { const base = { title: 't', createdAt: Date.now(), postContent: [], }; it('invalid when required fields missing', () => { expect(checkStructure({})).toBe(false); expect(checkStructure({ ...base, title: '' })).toBe(false); expect(checkStructure({ ...base, createdAt: 0 })).toBe(false); }); it('valid with proper content blocks', () => { const content = [ { type: 'editor', version: 1, id: 'e1', content: [{ text: 'hello' }] }, { type: 'image', version: 1, id: 'i1', content: { image: 'data:' } }, ]; expect(checkStructure({ ...base, postContent: content })).toBe(true); }); it('invalid with unsupported type for version 1', () => { const content = [{ type: 'unknown', version: 1, id: 'x', content: {} }]; expect(checkStructure({ ...base, postContent: content })).toBe(false); }); }); describe('checkStructureMailMessages', () => { it('valid minimal', () => { const mail = { createdAt: Date.now(), version: 1, attachments: [], textContent: [], generalData: {}, }; expect(checkStructureMailMessages(mail)).toBe(true); }); it('invalid if arrays/objects missing', () => { expect(checkStructureMailMessages({})).toBe(false); }); });