diff options
author | Anders Kaseorg <andersk@mit.edu> | 2021-09-13 20:53:13 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-09-13 23:07:45 +0300 |
commit | 0320bd77e2a38f48a88e377df4b122fd21043a83 (patch) | |
tree | b961b270e8a426e82a13cea06357f4cb52ce9394 /test | |
parent | 59743972c2ae1d2dd601aaa6c59974c686b1cb29 (diff) |
fix(view): Show the correct publish date for versions selected by range
Before, `npm view npm@^6` would incorrectly report “published over a
year from now” for every entry. Now it reports the correct dates.
PR-URL: https://github.com/npm/cli/pull/3739
Credit: @andersk
Close: #3739
Reviewed-by: @wraithgar
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/view.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/lib/view.js b/test/lib/view.js index 793917adc..096ababb2 100644 --- a/test/lib/view.js +++ b/test/lib/view.js @@ -17,6 +17,9 @@ const cleanLogs = () => { console.log = fn } +// 25 hours ago +const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 25) + const packument = (nv, opts) => { if (!opts.fullMetadata) throw new Error('must fetch fullMetadata') @@ -40,7 +43,7 @@ const packument = (nv, opts) => { latest: '1.0.0', }, time: { - '1.0.0': '2019-08-06T16:21:09.842Z', + '1.0.0': yesterday, }, versions: { '1.0.0': { @@ -332,6 +335,13 @@ t.test('should log package info', t => { }) }) + t.test('package with semver range', t => { + view.exec(['blue@^1.0.0'], () => { + t.matchSnapshot(logs) + t.end() + }) + }) + t.test('package with no modified time', t => { viewUnicode.exec(['cyan@1.0.0'], () => { t.matchSnapshot(logs) |