Skip to content

Commit

Permalink
test: update hidden package-lock mtime in ls test
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 25, 2021
1 parent 238e474 commit 8969235
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ const { resolve } = require('path')
const t = require('tap')
const requireInject = require('require-inject')

const { utimesSync } = require('fs')
const touchHiddenPackageLock = prefix => {
const later = new Date(Date.now() + 10000)
utimesSync(`${prefix}/node_modules/.package-lock.json`, later, later)
}

t.cleanSnapshot = str => str.split(/\r\n/).join('\n')

const simpleNmFixture = {
Expand Down Expand Up @@ -1186,6 +1192,7 @@ t.test('ls', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should output tree containing aliases')
t.end()
Expand Down Expand Up @@ -1231,6 +1238,7 @@ t.test('ls', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], (err) => {
t.ifError(err, 'npm ls')
t.matchSnapshot(redactCwd(result), 'should output tree containing git refs')
Expand Down Expand Up @@ -1329,6 +1337,7 @@ t.test('ls', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should not be printed in tree output')
t.end()
Expand Down Expand Up @@ -2228,6 +2237,7 @@ t.test('ls --parseable', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should output tree containing aliases')
t.end()
Expand Down Expand Up @@ -2272,6 +2282,7 @@ t.test('ls --parseable', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should output tree containing git refs')
t.end()
Expand Down Expand Up @@ -2325,6 +2336,7 @@ t.test('ls --parseable', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.matchSnapshot(redactCwd(result), 'should not be printed in tree output')
t.end()
Expand Down Expand Up @@ -3688,6 +3700,7 @@ t.test('ls --json', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.deepEqual(
jsonParse(result),
Expand Down Expand Up @@ -3747,6 +3760,7 @@ t.test('ls --json', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.deepEqual(
jsonParse(result),
Expand Down Expand Up @@ -3830,6 +3844,7 @@ t.test('ls --json', (t) => {
},
},
})
touchHiddenPackageLock(prefix)
ls([], () => {
t.deepEqual(
jsonParse(result),
Expand Down

0 comments on commit 8969235

Please sign in to comment.