File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ test('timeout with streams', async t => {
144
144
await t . throws ( pEvent ( stream , 'response' ) , { code : 'ETIMEDOUT' } ) ;
145
145
} ) ;
146
146
147
- test ( 'no error emitted when timeout is not breached' , async t => {
147
+ test ( 'no error emitted when timeout is not breached (stream) ' , async t => {
148
148
const stream = got . stream ( s . url , {
149
149
retry : 0 ,
150
150
timeout : {
@@ -158,3 +158,20 @@ test('no error emitted when timeout is not breached', async t => {
158
158
await delay ( reqDelay * 3 ) ;
159
159
t . pass ( ) ;
160
160
} ) ;
161
+
162
+ test ( 'no error emitted when timeout is not breached (promise)' , async t => {
163
+ await got ( s . url , {
164
+ retry : 0 ,
165
+ timeout : {
166
+ request : reqDelay * 2
167
+ }
168
+ } ) . on ( 'request' , req => {
169
+ // 'error' events are not emitted by the Promise interface, so attach
170
+ // directly to the request object
171
+ req . on ( 'error' , err => {
172
+ t . fail ( `error was emitted: ${ err } ` ) ;
173
+ } ) ;
174
+ } ) ;
175
+ await delay ( reqDelay * 3 ) ;
176
+ t . pass ( ) ;
177
+ } ) ;
You can’t perform that action at this time.
0 commit comments