import { describe, it, expect } from 'vitest'; import type { LintResult, DocumentMetadata, ValidationContext, Validator, Severity, } from '../../src/core/types.js'; describe('core/types', () => { describe('LintResult', () => { it('should have required fields', () => { const result: LintResult = { ruleId: 'text/frontmatter/missing', ruleName: 'frontmatter必須', severity: 'error', message: 'frontmatterがありません', }; expect(result.ruleId).toBe('text/frontmatter/missing'); expect(result.ruleName).toBe('frontmatter必須'); expect(result.severity).toBe('error'); expect(result.message).toBe('frontmatterがありません'); }); it('should support optional fields', () => { const result: LintResult = { ruleId: 'text/frontmatter/missing-title', ruleName: 'title必須', severity: 'error', message: 'frontmatterに「title」フィールドがありません', location: { line: 1, column: 1, }, detail: '詳細説明', suggestion: '修正提案', context: { found: 'actual value', expected: 'expected value', }, }; expect(result.location?.line).toBe(1); expect(result.detail).toBe('詳細説明'); expect(result.suggestion).toBe('修正提案'); expect(result.context?.found).toBe('actual value'); }); }); describe('DocumentMetadata', () => { it('should have required fields', () => { const metadata: DocumentMetadata = { filePath: '/path/to/file.md', frontmatter: {}, }; expect(metadata.filePath).toBe('/path/to/file.md'); expect(metadata.frontmatter).toEqual({}); }); it('should support optional title', () => { const metadata: DocumentMetadata = { filePath: '/path/to/file.md', title: 'Test Title', frontmatter: { title: 'Test Title', draft: false }, }; expect(metadata.title).toBe('Test Title'); }); }); describe('Severity', () => { it('should accept valid severity values', () => { const severities: Severity[] = ['error', 'warning', 'info']; expect(severities).toHaveLength(3); }); }); describe('Validator interface', () => { it('should define validator contract', () => { const mockValidator: Validator = { id: 'test/validator', name: 'テストバリデーター', validate: (_context: ValidationContext) => [], }; expect(mockValidator.id).toBe('test/validator'); expect(mockValidator.name).toBe('テストバリデーター'); expect(typeof mockValidator.validate).toBe('function'); }); }); });