diff options
author | Rebecca Turner <me@re-becca.org> | 2017-05-10 23:19:25 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2017-05-26 04:55:12 +0300 |
commit | 9215148812450209e4e2215e9cf3a9f495b7f64f (patch) | |
tree | 49586f7923517e64970503011a88e8eaf1e0d81e /test | |
parent | 031b7b76afd55c5c99eb4cdf7d094142071d967c (diff) |
test: tests that pass w/ shrinkwrap API fix
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/install-shrinkwrapped-git.js (renamed from test/need-npm5-update/install-shrinkwrapped-git.js) | 0 | ||||
-rw-r--r-- | test/tap/shrinkwrap-optional-dependency.js (renamed from test/need-npm5-update/shrinkwrap-optional-dependency.js) | 0 | ||||
-rw-r--r-- | test/tap/shrinkwrap-optional-property.js (renamed from test/need-npm5-update/shrinkwrap-optional-property.js) | 0 | ||||
-rw-r--r-- | test/tap/shrinkwrap-prod-dependency.js (renamed from test/need-npm5-update/shrinkwrap-prod-dependency.js) | 0 | ||||
-rw-r--r-- | test/tap/shrinkwrap-shared-dev-dependency.js (renamed from test/need-npm5-update/shrinkwrap-shared-dev-dependency.js) | 95 |
5 files changed, 47 insertions, 48 deletions
diff --git a/test/need-npm5-update/install-shrinkwrapped-git.js b/test/tap/install-shrinkwrapped-git.js index f697980de..f697980de 100644 --- a/test/need-npm5-update/install-shrinkwrapped-git.js +++ b/test/tap/install-shrinkwrapped-git.js diff --git a/test/need-npm5-update/shrinkwrap-optional-dependency.js b/test/tap/shrinkwrap-optional-dependency.js index 0e9b3b202..0e9b3b202 100644 --- a/test/need-npm5-update/shrinkwrap-optional-dependency.js +++ b/test/tap/shrinkwrap-optional-dependency.js diff --git a/test/need-npm5-update/shrinkwrap-optional-property.js b/test/tap/shrinkwrap-optional-property.js index 52deba863..52deba863 100644 --- a/test/need-npm5-update/shrinkwrap-optional-property.js +++ b/test/tap/shrinkwrap-optional-property.js diff --git a/test/need-npm5-update/shrinkwrap-prod-dependency.js b/test/tap/shrinkwrap-prod-dependency.js index cdb6416cc..cdb6416cc 100644 --- a/test/need-npm5-update/shrinkwrap-prod-dependency.js +++ b/test/tap/shrinkwrap-prod-dependency.js diff --git a/test/need-npm5-update/shrinkwrap-shared-dev-dependency.js b/test/tap/shrinkwrap-shared-dev-dependency.js index 1683dc2ad..0414ac8c2 100644 --- a/test/need-npm5-update/shrinkwrap-shared-dev-dependency.js +++ b/test/tap/shrinkwrap-shared-dev-dependency.js @@ -3,43 +3,44 @@ var path = require('path') var mkdirp = require('mkdirp') var mr = require('npm-registry-mock') -var osenv = require('osenv') var rimraf = require('rimraf') var test = require('tap').test var common = require('../common-tap.js') -var npm = npm = require('../../') -var pkg = path.resolve(__dirname, 'shrinkwrap-shared-dev-dependency') +var pkg = path.resolve(__dirname, path.basename(__filename, '.js')) -test("shrinkwrap doesn't strip out the shared dependency", function (t) { - t.plan(1) - - mr({ port: common.port }, function (er, s) { - setup(function (err) { - if (err) return t.fail(err) - - npm.install('.', function (err) { - if (err) return t.fail(err) - npm.config.set('dev', true) // npm install unsets this +var opts = { + env: common.newEnv().extend({ + npm_config_cache: path.resolve(pkg, 'cache'), + npm_config_registry: common.registry + }), + stdio: [0, 1, 2], + cwd: pkg +} - npm.commands.shrinkwrap([], true, function (err, results) { - if (err) return t.fail(err) +var json = { + author: 'Domenic Denicola', + name: 'npm-test-shrinkwrap-shared-dev-dependency', + version: '0.0.0', + dependencies: { + 'test-package-with-one-dep': '0.0.0' + }, + devDependencies: { + 'test-package': '0.0.0' + } +} - t.deepEqual(results, desired) - s.close() - t.end() - }) - }) - }) +var server +test('setup', function (t) { + setup() + mr({ port: common.port }, function (er, s) { + if (er) throw er + server = s + t.done() }) }) -test('cleanup', function (t) { - cleanup() - t.end() -}) - var desired = { name: 'npm-test-shrinkwrap-shared-dev-dependency', version: '0.0.0', @@ -57,34 +58,32 @@ var desired = { } } -var json = { - author: 'Domenic Denicola', - name: 'npm-test-shrinkwrap-shared-dev-dependency', - version: '0.0.0', - dependencies: { - 'test-package-with-one-dep': '0.0.0' - }, - devDependencies: { - 'test-package': '0.0.0' - } -} +test("shrinkwrap doesn't strip out the shared dependency", function (t) { + t.plan(3) + + return common.npm(['install'], opts).spread((code) => { + t.is(code, 0, 'install') + return common.npm(['shrinkwrap'], opts) + }).spread((code) => { + t.is(code, 0, 'shrinkwrap') + var results = JSON.parse(fs.readFileSync(`${pkg}/npm-shrinkwrap.json`)) + t.deepEqual(results, desired) + t.end() + }) +}) -function setup (cb) { +test('cleanup', function (t) { + server.close() + cleanup() + t.end() +}) + +function setup () { cleanup() mkdirp.sync(pkg) fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2)) - process.chdir(pkg) - - var opts = { - cache: path.resolve(pkg, 'cache'), - registry: common.registry, - // important to make sure devDependencies don't get stripped - dev: true - } - npm.load(opts, cb) } function cleanup () { - process.chdir(osenv.tmpdir()) rimraf.sync(pkg) } |