From 0b1bc8680568a7671c189306f76f2f1e58ef88cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6nnemann?= Date: Tue, 18 Aug 2015 13:05:59 +0200 Subject: [PATCH] test(initial-release): add test case for empty request body --- test/mocks/registry.js | 2 ++ test/specs/index.js | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/mocks/registry.js b/test/mocks/registry.js index 2d570df..1c2bd9c 100644 --- a/test/mocks/registry.js +++ b/test/mocks/registry.js @@ -26,3 +26,5 @@ module.exports = nock('http://registry.npmjs.org') .reply(200, availableModule) .get('/unavailable') .reply(404, {}) + .get('/unavailable-no-body') + .reply(404) diff --git a/test/specs/index.js b/test/specs/index.js index b947d78..94dc8c0 100644 --- a/test/specs/index.js +++ b/test/specs/index.js @@ -6,7 +6,8 @@ const lastRelease = require('../../') const npm = { registry: 'http://registry.npmjs.org/', - tag: 'latest' + tag: 'latest', + loglevel: 'error' } test('last release from registry', (t) => { @@ -66,14 +67,22 @@ test('last release from registry', (t) => { }) t.test('get nothing from not yet published package name', (tt) => { + tt.plan(4) + lastRelease({}, { pkg: {name: 'unavailable'}, npm }, (err, release) => { tt.error(err) tt.is(release.version, undefined, 'no version') + }) - tt.end() + lastRelease({}, { + pkg: {name: 'unavailable-no-body'}, + npm + }, (err, release) => { + tt.error(err) + tt.is(release.version, undefined, 'no version') }) }) })