profileShare

rasmusjy / voicetask

Read-only snapshot

No repository description.

main default branch 105 files Expires Sep 13, 2026, 9:06 AM
provenance.test.ts 1,410 bytes
1 import { describe, expect, it } from 'vitest'
2 import { validateProvenance } from './provenance'
3
4 describe('validateProvenance', () => {
5 it('leaves lines with only valid markers untouched', () => {
6 const content = '- FR-001: does a thing. [S1][S2]'
7 const { content: result, invalidMarkerCount } = validateProvenance(content, new Set(['S1', 'S2']))
8 expect(result).toBe(content)
9 expect(invalidMarkerCount).toBe(0)
10 })
11
12 it('removes an invalid marker and appends [unverified]', () => {
13 const content = '- FR-002: does another thing. [S999]'
14 const { content: result, invalidMarkerCount } = validateProvenance(content, new Set(['S1']))
15 expect(result).toBe('- FR-002: does another thing. [unverified]')
16 expect(invalidMarkerCount).toBe(1)
17 })
18
19 it('keeps valid markers on a line while removing only the invalid ones', () => {
20 const content = '- FR-003: mixed evidence. [S1][S999]'
21 const { content: result, invalidMarkerCount } = validateProvenance(content, new Set(['S1']))
22 expect(result).toBe('- FR-003: mixed evidence. [S1] [unverified]')
23 expect(invalidMarkerCount).toBe(1)
24 })
25
26 it('does not duplicate [unverified] if already present', () => {
27 const content = '- FR-004: already flagged. [S999] [unverified]'
28 const { content: result } = validateProvenance(content, new Set())
29 expect(result).toBe('- FR-004: already flagged. [unverified]')
30 })
31 })
32