agenthub/tests/schema.test.ts
2026-06-24 23:29:32 +02:00

41 lines
1.2 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { TaskSchema, HandoffSchema, DecisionSchema, MemorySchema, StatusSchema, ConfigSchema } from '../src/core/schema.js';
describe('schemas', () => {
it('validates a minimal task', () => {
const result = TaskSchema.safeParse({
id: 'TSK-0001',
title: 'Implement DNS cache',
description: 'Add local cache',
status: 'open',
createdAt: '2026-06-24T10:00:00Z',
updatedAt: '2026-06-24T10:00:00Z',
});
expect(result.success).toBe(true);
});
it('rejects an invalid task id', () => {
const result = TaskSchema.safeParse({
id: 'task-1',
title: 'Implement DNS cache',
description: '',
status: 'open',
createdAt: '2026-06-24T10:00:00Z',
updatedAt: '2026-06-24T10:00:00Z',
});
expect(result.success).toBe(false);
});
it('rejects a task id without exactly 4 digits', () => {
const result = TaskSchema.safeParse({
id: 'TSK-1',
title: 'Implement DNS cache',
description: '',
status: 'open',
createdAt: '2026-06-24T10:00:00Z',
updatedAt: '2026-06-24T10:00:00Z',
});
expect(result.success).toBe(false);
});
});