diff --git a/lib/commands/view.js b/lib/commands/view.js index 0c3f232602f87..6d81968207629 100644 --- a/lib/commands/view.js +++ b/lib/commands/view.js @@ -208,7 +208,7 @@ class View extends BaseCommand { if (pckmnt.time && pckmnt.time.unpublished) { const u = pckmnt.time.unpublished - const er = new Error('Unpublished by ' + u.name + ' on ' + u.time) + const er = new Error(`Unpublished on ${u.time}`) er.statusCode = 404 er.code = 'E404' er.pkgid = pckmnt._id diff --git a/test/lib/commands/view.js b/test/lib/commands/view.js index 035490a79fbf7..e49133dad0688 100644 --- a/test/lib/commands/view.js +++ b/test/lib/commands/view.js @@ -32,12 +32,15 @@ const packument = (nv, opts) => { const mocks = { red: { + _id: 'red@1.0.1', name: 'red', 'dist-tags': { '1.0.1': {}, }, time: { - unpublished: new Date(), + unpublished: { + time: '2012-12-20T00:00:00.000Z', + }, }, }, blue: { @@ -533,7 +536,7 @@ t.test('throws when unpublished', async t => { const view = new View(npm) await t.rejects( view.exec(['red']), - { code: 'E404' } + { code: 'E404', pkgid: 'red@1.0.1', message: 'Unpublished on 2012-12-20T00:00:00.000Z' } ) })