Files
bilin/tests/main/knowledge-extraction.test.ts
T
bing a39e06ff07 feat: ship v0.8.0 with writing logs and AI knowledge extraction
Deliver P5.2 writing day logs, cockpit heatmap, streak tracking, and chapter knowledge auto-extraction with merge review.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 18:26:29 +08:00

19 lines
846 B
TypeScript

import { describe, it, expect } from 'vitest'
import { parseExtractionJson } from '../../src/main/services/knowledge-extraction-prompt'
describe('knowledge extraction', () => {
it('UT-EXT-01: parseExtractionJson parses valid array', () => {
const raw = `[{"type":"fact","title":"测灵石","content":"石头发热","confidence":0.9}]`
const items = parseExtractionJson(raw)
expect(items).toHaveLength(1)
expect(items[0].title).toBe('测灵石')
expect(items[0].confidence).toBe(0.9)
})
it('UT-EXT-02: parseExtractionJson handles markdown fence and suggestedMergeId', () => {
const raw = '```json\n[{"type":"character","title":"林凡","content":"主角","confidence":0.85,"suggestedMergeId":"abc-123"}]\n```'
const items = parseExtractionJson(raw)
expect(items[0].suggestedMergeId).toBe('abc-123')
})
})