@@ -11,11 +11,13 @@ vi.mock('@inkjs/ui', () => ({
1111 isDisabled,
1212 onChange,
1313 onSubmit,
14+ placeholder,
1415 } : {
1516 defaultValue ?: string ;
1617 isDisabled ?: boolean ;
1718 onChange ?: ( value : string ) => void ;
1819 onSubmit ?: ( value : string ) => void ;
20+ placeholder ?: string ;
1921 } ) => {
2022 const [ value , setValue ] = useState ( defaultValue ?? '' ) ;
2123 const valueRef = useRef ( defaultValue ?? '' ) ;
@@ -56,7 +58,16 @@ vi.mock('@inkjs/ui', () => ({
5658 setValue ( nextValue ) ;
5759 } ) ;
5860
59- return < Text > { value } </ Text > ;
61+ return (
62+ < >
63+ < Text > { value === '' ? ( placeholder ?? '' ) : value } </ Text >
64+ { value ? (
65+ < Text dimColor > { `[value:${ value } ]` } </ Text >
66+ ) : (
67+ < Text dimColor > { `[placeholder:${ placeholder ?? '' } ]` } </ Text >
68+ ) }
69+ </ >
70+ ) ;
6071 } ,
6172} ) ) ;
6273
@@ -169,6 +180,10 @@ describe('Input', () => {
169180 it ( 'renders input prompt' , ( ) => {
170181 const { lastFrame } = render ( < Input onSubmit = { vi . fn ( ) } /> ) ;
171182 expect ( lastFrame ( ) ) . toContain ( '>' ) ;
183+ expect ( lastFrame ( ) ) . toContain ( 'Ask anything... (/ commands, @ files)' ) ;
184+ expect ( lastFrame ( ) ) . toContain (
185+ '[placeholder:Ask anything... (/ commands, @ files)]' ,
186+ ) ;
172187 } ) ;
173188
174189 it ( 'does not show command suggestion on non-slash input' , async ( ) => {
@@ -337,9 +352,13 @@ describe('Input', () => {
337352 await test . tick ( ) ;
338353 stdin . write ( 'i' ) ;
339354 await test . tick ( ) ;
355+ expect ( lastFrame ( ) ) . toContain ( '[value:hi]' ) ;
340356 stdin . write ( KEY . ENTER ) ;
341357 await test . tick ( 10 ) ;
342- expect ( lastFrame ( ) ) . not . toContain ( 'hi' ) ;
358+ expect ( lastFrame ( ) ) . not . toContain ( '[value:hi]' ) ;
359+ expect ( lastFrame ( ) ) . toContain (
360+ '[placeholder:Ask anything... (/ commands, @ files)]' ,
361+ ) ;
343362 } ) ;
344363
345364 it ( 'deletes last character on backspace' , async ( ) => {
@@ -375,7 +394,10 @@ describe('Input', () => {
375394 ) ;
376395 stdin . write ( 'h' ) ;
377396 await test . tick ( ) ;
378- expect ( lastFrame ( ) ) . not . toContain ( 'h' ) ;
397+ expect ( lastFrame ( ) ) . not . toContain ( '[value:h]' ) ;
398+ expect ( lastFrame ( ) ) . toContain (
399+ '[placeholder:Ask anything... (/ commands, @ files)]' ,
400+ ) ;
379401 stdin . write ( KEY . ENTER ) ;
380402 await test . tick ( ) ;
381403 expect ( onSubmit ) . not . toHaveBeenCalled ( ) ;
0 commit comments