@@ -8,11 +8,11 @@ const ESCAPE = '\u001b'
88class FakeInput extends EventEmitter {
99 isTTY = true
1010 isRaw = false
11- paused = true
11+ readableFlowing : boolean | null = null
1212 readonly rawStates : boolean [ ] = [ ]
1313
1414 isPaused ( ) : boolean {
15- return this . paused
15+ return this . readableFlowing === false
1616 }
1717
1818 setRawMode ( value : boolean ) : this {
@@ -22,12 +22,12 @@ class FakeInput extends EventEmitter {
2222 }
2323
2424 resume ( ) : this {
25- this . paused = false
25+ this . readableFlowing = true
2626 return this
2727 }
2828
2929 pause ( ) : this {
30- this . paused = true
30+ this . readableFlowing = false
3131 return this
3232 }
3333}
@@ -42,9 +42,11 @@ class FakeOutput {
4242}
4343
4444describe ( 'promptSecret' , ( ) => {
45- it ( 'masks input and restores the terminal before returning it ' , async ( ) => {
45+ it ( 'masks input and pauses an initially idle terminal before returning' , async ( ) => {
4646 const input = new FakeInput ( )
4747 const output = new FakeOutput ( )
48+ expect ( input . isPaused ( ) ) . toBe ( false )
49+
4850 const result = promptSecret ( input as unknown as ReadStream , output )
4951
5052 input . emit ( 'keypress' , 'hunter2' , { name : 'h' } )
@@ -53,7 +55,7 @@ describe('promptSecret', () => {
5355 await expect ( result ) . resolves . toBe ( 'hunter2' )
5456 expect ( output . value ) . toBe ( 'Secret value: *******\n' )
5557 expect ( input . rawStates ) . toEqual ( [ true , false ] )
56- expect ( input . paused ) . toBe ( true )
58+ expect ( input . isPaused ( ) ) . toBe ( true )
5759 } )
5860
5961 it ( 'handles backspace without revealing the value' , async ( ) => {
@@ -88,6 +90,7 @@ describe('promptSecret', () => {
8890 await expect ( result ) . rejects . toThrow ( 'Secret input cancelled.' )
8991 await expect ( result ) . rejects . toBeInstanceOf ( SecretInputCancelledError )
9092 expect ( input . rawStates ) . toEqual ( [ true , false ] )
93+ expect ( input . isPaused ( ) ) . toBe ( true )
9194 } )
9295
9396 it ( 'keeps the character following a pasted escape byte' , async ( ) => {
0 commit comments