@@ -29,6 +29,7 @@ const mockDisplay = async (t, { mocks, load } = {}) => {
29
29
...procLog ,
30
30
display,
31
31
displayLoad,
32
+ streams : logs . streams ,
32
33
...logs . logs ,
33
34
}
34
35
}
@@ -101,6 +102,50 @@ t.test('can do progress', async (t) => {
101
102
t . strictSame ( outputs , [ 'before input' , 'during input' , 'after input' ] )
102
103
} )
103
104
105
+ t . test ( 'progress resume does not clear output when spinner inactive' , async ( t ) => {
106
+ const { input, output, outputs, streams } = await mockDisplay ( t , {
107
+ load : {
108
+ progress : true ,
109
+ } ,
110
+ } )
111
+
112
+ const origClearLine = streams . stderr . clearLine
113
+ const origCursorTo = streams . stderr . cursorTo
114
+ let clearCalls = 0
115
+ let cursorCalls = 0
116
+ streams . stderr . clearLine = ( ...args ) => {
117
+ clearCalls ++
118
+ return origClearLine . call ( streams . stderr , ...args )
119
+ }
120
+ streams . stderr . cursorTo = ( ...args ) => {
121
+ cursorCalls ++
122
+ return origCursorTo . call ( streams . stderr , ...args )
123
+ }
124
+
125
+ t . teardown ( ( ) => {
126
+ streams . stderr . clearLine = origClearLine
127
+ streams . stderr . cursorTo = origCursorTo
128
+ } )
129
+
130
+ // ensure the spinner has rendered at least once so progress.off clears it
131
+ await timers . setTimeout ( 300 )
132
+
133
+ const endInput = input . start ( )
134
+ await timers . setTimeout ( 0 )
135
+
136
+ clearCalls = 0
137
+ cursorCalls = 0
138
+
139
+ output . standard ( 'no trailing newline' )
140
+
141
+ endInput ( )
142
+ await timers . setTimeout ( 0 )
143
+
144
+ t . equal ( clearCalls , 0 , 'resume does not clear the line when spinner inactive' )
145
+ t . equal ( cursorCalls , 0 , 'resume does not reposition cursor when spinner inactive' )
146
+ t . equal ( outputs . at ( - 1 ) , 'no trailing newline' , 'output remains visible' )
147
+ } )
148
+
104
149
t . test ( 'handles log throwing' , async ( t ) => {
105
150
class ThrowInspect {
106
151
#crashes = 0 ;
0 commit comments