diff options
Diffstat (limited to 'deps/npm/test/tap/verify-no-lifecycle-on-repo.js')
-rw-r--r-- | deps/npm/test/tap/verify-no-lifecycle-on-repo.js | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/deps/npm/test/tap/verify-no-lifecycle-on-repo.js b/deps/npm/test/tap/verify-no-lifecycle-on-repo.js index 29f79e29833..eedaa756b8f 100644 --- a/deps/npm/test/tap/verify-no-lifecycle-on-repo.js +++ b/deps/npm/test/tap/verify-no-lifecycle-on-repo.js @@ -4,7 +4,8 @@ var fs = require('graceful-fs') var mkdirp = require('mkdirp') var rimraf = require('rimraf') var test = require('tap').test -var common = require('../common-tap.js') +var requireInject = require('require-inject') +require('../common-tap.js') var base = path.join(__dirname, path.basename(__filename, '.js')) @@ -20,6 +21,17 @@ var baseJSON = { } } +var lastOpened +var npm = requireInject.installGlobally('../../lib/npm.js', { + '../../lib/utils/lifecycle.js': function (pkg, stage, wd, unsafe, failOk, cb) { + cb(new Error("Shouldn't be calling lifecycle scripts")) + }, + opener: function (url, options, cb) { + lastOpened = {url: url, options: options} + cb() + } +}) + test('setup', function (t) { cleanup() setup() @@ -27,11 +39,14 @@ test('setup', function (t) { }) test('repo', function (t) { - common.npm(['repo', '--browser=echo'], {cwd: base}, function (er, code, stdout, stderr) { - t.ifError(er, 'npm config ran without issue') - t.is(code, 0, 'exited with a non-error code') - t.is(stderr, '', 'Ran without errors') - t.end() + process.chdir(base) + npm.load({browser: 'echo'}, function () { + npm.commands.repo([], function (err) { + t.ifError(err, 'no errors') + t.match(lastOpened.url, baseJSON.repository.url, 'opened the right url') + t.is(lastOpened.options.command, 'echo', 'opened with a specified browser') + t.end() + }) }) }) |