From 08a97e7243ff18a841da431b197e25d6a6c8747e Mon Sep 17 00:00:00 2001 From: Victor Yelevich Date: Wed, 7 Oct 2015 17:22:42 -0700 Subject: [PATCH 1/2] Only JSON parse when response body is not empty --- lib/dnsmadeeasy/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dnsmadeeasy/core.js b/lib/dnsmadeeasy/core.js index d425a36..4376520 100644 --- a/lib/dnsmadeeasy/core.js +++ b/lib/dnsmadeeasy/core.js @@ -104,7 +104,7 @@ _.extend(Client.prototype, { if (err) { return reject(err); } - resolve(JSON.parse(body)); + resolve((body && body.length > 0) ? JSON.parse(body) : body); }); }); }, From 78a06a782686e5c8d6b00b7c010efb8af342ee7a Mon Sep 17 00:00:00 2001 From: Mark Stosberg Date: Mon, 30 Jan 2017 21:21:59 -0500 Subject: [PATCH 2/2] test(deleteRecordForDomain): Fix bad mock of API response. As documented on page 24 of the REST API docs, an empty response is returned, not JSON. --- lib/dnsmadeeasy/managedDns.spec.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/dnsmadeeasy/managedDns.spec.js b/lib/dnsmadeeasy/managedDns.spec.js index 433e8c0..c6ff936 100644 --- a/lib/dnsmadeeasy/managedDns.spec.js +++ b/lib/dnsmadeeasy/managedDns.spec.js @@ -408,16 +408,12 @@ describe('ManagedDns', function() { reqheaders: headers }) .post('/dns/managed/1/records') - .reply(200, { - status: 'ok' - }); + .reply(200); var managedDns = ManagedDns.createManagedDNS(client); var response = yield managedDns.createRecordForDomain(1, {}); - expect(response).to.be.eql({ - status: 'ok' - }); + expect(response).to.be.equal(''); }); });