char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1import { findCommandToken , takeCommandDismissSnapshot } from '$lib/utils' ; 2import { describe , expect , it } from 'vitest' ; 3 4describe ( 'findCommandToken' , () => { 5it ( 'returns null when the value does not start with a slash' , () => { 6expect ( findCommandToken ( 'hello /prompt' )). toBeNull (); 7expect ( findCommandToken ( '' )). toBeNull (); 8expect ( findCommandToken ( 'prompt' )). toBeNull (); 9}); 10 11it ( 'parses a bare slash' , () => { 12expect ( findCommandToken ( '/' )). toEqual ({ args :'' , end :1 , name :'' }); 13}); 14 15it ( 'parses a command name with no args' , () => { 16expect ( findCommandToken ( '/prompt' )). toEqual ({ args :'' , end :7 , name :'prompt' }); 17}); 18 19it ( 'parses a command name followed by a space' , () => { 20expect ( findCommandToken ( '/prompt ' )). toEqual ({ args :'' , end :8 , name :'prompt' }); 21}); 22 23it ( 'parses args after the command name' , () => { 24expect ( findCommandToken ( '/prompt rev' )). toEqual ({ args :'rev' , end :11 , name :'prompt' }); 25}); 26 27it ( 'parses multi-word args' , () => { 28expect ( findCommandToken ( '/prompt review code ' )). toEqual ({ 29args :' review code ' , 30end :22 , 31name :'prompt' 32}); 33}); 34 35it ( 'treats the whole run as the name when there is no space' , () => { 36expect ( findCommandToken ( '/promptx' )). toEqual ({ args :'' , end :8 , name :'promptx' }); 37}); 38}); 39 40describe ( 'takeCommandDismissSnapshot' , () => { 41it ( 'returns null when there is no command token' , () => { 42expect ( takeCommandDismissSnapshot ( 'hello' )). toBeNull (); 43}); 44 45it ( 'captures the name and args' , () => { 46expect ( takeCommandDismissSnapshot ( '/prompt rev' )). toEqual ({ 47args :'rev' , 48name :'prompt' 49}); 50}); 51});