24 lines
965 B
TypeScript
24 lines
965 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { createSnapshot, deduplicateDocuments } from '../src/model.js'
|
|
|
|
describe('deduplicateDocuments', () => {
|
|
it('deduplicates Windows paths and preserves dirty state', () => {
|
|
const result = deduplicateDocuments([
|
|
{ path: 'F:\\Project\\main.ts', label: 'main.ts', dirty: false },
|
|
{ path: 'f:\\project\\MAIN.ts', label: 'MAIN.ts', dirty: true },
|
|
])
|
|
expect(result).toEqual([{ path: 'f:\\project\\MAIN.ts', label: 'MAIN.ts', dirty: true }])
|
|
})
|
|
})
|
|
|
|
describe('createSnapshot', () => {
|
|
it('creates the frozen v1 wire shape', () => {
|
|
const snapshot = createSnapshot({
|
|
instanceId: 'one', processId: 12, workspace: 'F:\\Project',
|
|
documents: [{ path: 'F:\\Project\\main.ts', label: 'main.ts', dirty: false }],
|
|
now: new Date('2026-01-01T00:00:00.000Z'),
|
|
})
|
|
expect(snapshot).toMatchObject({ version: 1, ide: 'vscode', updatedAt: '2026-01-01T00:00:00.000Z' })
|
|
})
|
|
})
|