Skip to content

Commit

Permalink
fixup! test: add lib/update.js tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ruyadorno committed Dec 2, 2020
1 parent 7c9811c commit 9548a70
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/lib/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,30 @@ t.test('update --depth=<number>', t => {
})

t.test('update --global', t => {
t.plan(1)
t.plan(2)

const normalizePath = p => p.replace(/\\+/g, '/')
const redactCwd = (path) => normalizePath(path)
.replace(new RegExp(normalizePath(process.cwd()), 'g'), '{CWD}')

npm.prefix = '/project/a'
npm.globalDir = resolve(process.cwd(), '/global/lib/node_modules')
npm.globalDir = resolve(process.cwd(), 'global/lib/node_modules')
npm.flatOptions.global = true

class Arborist {
constructor (args) {
const { path, ...opts } = args
t.deepEqual(
{
...opts,
path: redactCwd(path),
},
{ ...npm.flatOptions, path: '/global/lib' },
opts,
npm.flatOptions,
'should call arborist contructor with expected options'
)

t.equal(
redactCwd(path),
'{CWD}/global/lib',
'should run with expected prefix'
)
}

reify () {}
Expand Down

0 comments on commit 9548a70

Please sign in to comment.