feat(w5): ship v2.0.0 platform sync, undo persistence, and updates
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
import { DatabaseSync } from 'node:sqlite'
|
||||
import { migrate } from '../../src/main/db/migrate'
|
||||
import { UndoStackService } from '../../src/main/services/undo-stack.service'
|
||||
import { VolumeRepository } from '../../src/main/db/repositories/volume.repo'
|
||||
import { ChapterRepository } from '../../src/main/db/repositories/chapter.repo'
|
||||
import type { SqliteDb } from '../../src/main/db/types'
|
||||
|
||||
describe('UndoStackService', () => {
|
||||
let db: SqliteDb
|
||||
let svc: UndoStackService
|
||||
let chapterId: string
|
||||
|
||||
beforeEach(() => {
|
||||
db = new DatabaseSync(':memory:')
|
||||
migrate(db)
|
||||
svc = new UndoStackService(db)
|
||||
const vol = new VolumeRepository(db).create('卷一', 0)
|
||||
chapterId = new ChapterRepository(db).create(vol.id, '第一章', 0).id
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
db.close()
|
||||
})
|
||||
|
||||
it('UT-UNDO-01: push and list undo entries', () => {
|
||||
svc.push(chapterId, { type: 'doc', content: '<p>旧内容</p>' })
|
||||
svc.push(chapterId, { type: 'doc', content: '<p>新内容</p>' })
|
||||
const list = svc.list(chapterId)
|
||||
expect(list).toHaveLength(2)
|
||||
expect(list[0]?.operation.content).toContain('新内容')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user