char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
4dee52f82
char/aliceai-t5-moe
1import { splitMentionSegments } from '$lib/utils/mention-badge' ; 2import { describe , expect , it } from 'vitest' ; 3 4describe ( 'splitMentionSegments' , () => { 5it ( 'returns a single plain run when there is no mention' , () => { 6const segments = splitMentionSegments ( '# not a heading here' ); 7 8expect ( segments ). toEqual ([{ mention :null , text :'# not a heading here' }]); 9}); 10 11it ( 'splits text around a mention' , () => { 12const segments = splitMentionSegments ( 'look at [main.c](file:///src/main.c) please' ); 13 14expect ( segments . map (( segment ) => segment . text )). toEqual ([ 15'look at ' , 16'[main.c](file:///src/main.c)' , 17' please' 18]); 19expect ( segments [ 1 ]. mention ). toEqual ({ name :'main.c' , path :'/src/main.c' }); 20}); 21 22it ( 'decodes percent-encoded paths' , () => { 23const segments = splitMentionSegments ( '[a b.txt](file:///tmp/a%20b.txt)' ); 24 25expect ( segments [ 0 ]. mention ?. path ). toBe ( '/tmp/a b.txt' ); 26}); 27 28it ( 'keeps the directory marker so the folder icon is picked' , () => { 29const segments = splitMentionSegments ( '[src](file:///repo/src/)' ); 30 31expect ( segments [ 0 ]. mention ?. path ). toBe ( '/repo/src/' ); 32}); 33 34it ( 'handles adjacent mentions with no text between them' , () => { 35const segments = splitMentionSegments ( '[a](file:///a)[b](file:///b)' ); 36 37expect ( segments ). toHaveLength ( 2 ); 38expect ( segments . every (( segment ) => segment . mention !== null )). toBe ( true ); 39}); 40 41it ( 'preserves the exact source when segments are joined back' , () => { 42const source = 'see [a](file:///a) and [b](file:///b/) done' ; 43 44expect ( splitMentionSegments ( source ). reduce (( acc , segment ) => acc + segment . text , '' )). toBe ( 45source 46); 47}); 48});