Skip to content

Commit 46238f6

Browse files
authored
tests: add passing case for document fetch error catching (#1294)
1 parent 2eb5ae0 commit 46238f6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/client.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,18 @@ describe('http', () => {
226226
done(err)
227227
})
228228
})
229+
230+
it('should err gracefully when requesting https from an http server', () => {
231+
return Swagger({
232+
url: 'http://localhost:8000/petstore.json',
233+
requestInterceptor: (req) => {
234+
const u = url.parse(req.url)
235+
u.protocol = 'https'
236+
req.url = u.format()
237+
return req
238+
}
239+
}).catch((err) => {
240+
expect(err.message).toEqual('request to https://localhost:8000/petstore.json failed, reason: socket hang up')
241+
})
242+
})
229243
})

0 commit comments

Comments
 (0)