From 9638035c2451e4b181b4a0265cbfd1dfa6870167 Mon Sep 17 00:00:00 2001 From: Aileen Nowak Date: Wed, 13 Sep 2017 16:08:16 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=20Replace=20http=20and=20https=20w?= =?UTF-8?q?ith=20got?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #99 - Used [`got`](https://github.com/sindresorhus/got) for image-size requests, which is more lightweight and has the huge advantage of following redirects - Added and updated test - indents --- lib/.DS_Store | Bin 0 -> 6148 bytes lib/amperize.js | 88 ++++++++++++++++++++++++------------------ package.json | 4 +- test/amperize.test.js | 57 +++++++++++++++++++++++---- 4 files changed, 103 insertions(+), 46 deletions(-) create mode 100644 lib/.DS_Store diff --git a/lib/.DS_Store b/lib/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0' + body: '' }); sizeOfStub.returns({width: 50, height: 50, type: 'jpg'}); @@ -118,7 +119,7 @@ describe('Amperize', function () { sizeOfMock = nock('http://static.wixstatic.com') .get('/media/355241_d31358572a2542c5a44738ddcb59e7ea.jpg_256') .reply(200, { - data: '' + body: '' }); sizeOfStub.returns({width: 350, height: 200, type: 'jpg'}); @@ -141,7 +142,7 @@ describe('Amperize', function () { sizeOfMock = nock('https://media.giphy.com') .get('/media/l46CtzgjhTm29Cbjq/giphy.gif') .reply(200, { - data: '' + body: '' }); sizeOfStub.returns({width: 800, height: 600, type: 'gif'}); @@ -230,6 +231,15 @@ describe('Amperize', function () { }); }); + it('can handle invalid URLs', function (done) { + amperize.parse('', function (error, result) { + expect(result).to.exist; + expect(Amperize.__get__('called')).to.be.equal(true); + expect(result).to.be.equal(''); + done(); + }); + }); + it('can handle