From 0ecaa011ed29b6e1c264a2ac0b4ebc26b5503cba Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Thu, 19 Apr 2018 18:39:50 -0700 Subject: [PATCH] tests: add passing case for document fetch error catching --- test/client.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/client.js b/test/client.js index 0fbe30c79..50c8f9b7a 100644 --- a/test/client.js +++ b/test/client.js @@ -226,4 +226,18 @@ describe('http', () => { done(err) }) }) + + it('should err gracefully when requesting https from an http server', () => { + return Swagger({ + url: 'http://localhost:8000/petstore.json', + requestInterceptor: (req) => { + const u = url.parse(req.url) + u.protocol = 'https' + req.url = u.format() + return req + } + }).catch((err) => { + expect(err.message).toEqual('request to https://localhost:8000/petstore.json failed, reason: socket hang up') + }) + }) })