import { describe, expect, it } from 'vitest' import { isLikelyReferenceSegment, splitReferenceSegment, } from '@/lib/workflows/sanitization/references' describe('splitReferenceSegment', () => { it('should return leading and reference for simple segments', () => { const result = splitReferenceSegment('') expect(result).toEqual({ leading: '', reference: '', }) }) it('should separate comparator prefixes from reference', () => { const result = splitReferenceSegment('< ') expect(result).toEqual({ leading: '< ', reference: '', }) }) it('should handle <= comparator prefixes', () => { const result = splitReferenceSegment('<= ') expect(result).toEqual({ leading: '<= ', reference: '', }) }) }) describe('isLikelyReferenceSegment', () => { it('should return true for regular references', () => { expect(isLikelyReferenceSegment('')).toBe(true) }) it('should return true for references after comparator', () => { expect(isLikelyReferenceSegment('< ')).toBe(true) expect(isLikelyReferenceSegment('<= ')).toBe(true) }) it('should return false when leading content is not comparator characters', () => { expect(isLikelyReferenceSegment('')).toBe(false) }) it('should return true for references starting with a digit', () => { expect(isLikelyReferenceSegment('<1password1>')).toBe(true) expect(isLikelyReferenceSegment('<1password1.secret>')).toBe(true) }) it('should return false for purely numeric references', () => { expect(isLikelyReferenceSegment('<123>')).toBe(false) }) })