summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/install-save-exact.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/tap/install-save-exact.js')
-rw-r--r--deps/npm/test/tap/install-save-exact.js84
1 files changed, 26 insertions, 58 deletions
diff --git a/deps/npm/test/tap/install-save-exact.js b/deps/npm/test/tap/install-save-exact.js
index 3d57ead361..efa1e63613 100644
--- a/deps/npm/test/tap/install-save-exact.js
+++ b/deps/npm/test/tap/install-save-exact.js
@@ -3,12 +3,10 @@ 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 server
var pkg = common.pkg
@@ -20,53 +18,32 @@ var json = {
description: 'fixture'
}
-test('setup', function (t) {
- setup()
+test('mock registry', function (t) {
mr({ port: common.port }, function (er, s) {
- server = s
+ t.parent.teardown(() => s.close())
t.end()
})
})
-test('\'npm install --save --save-exact\' should install local pkg', function (t) {
- common.npm(
- [
- '--loglevel', 'silent',
- '--registry', common.registry,
- '--save',
- '--save-exact',
- 'install', 'underscore@1.3.1'
- ],
- EXEC_OPTS,
- function (err, code) {
- t.ifError(err, 'npm ran without issue')
- t.notOk(code, 'npm install exited without raising an error code')
-
- var p = path.resolve(pkg, 'node_modules/underscore/package.json')
- t.ok(JSON.parse(fs.readFileSync(p)))
-
- p = path.resolve(pkg, 'package.json')
- var pkgJson = JSON.parse(fs.readFileSync(p, 'utf8'))
-
- t.same(
- pkgJson.dependencies,
- { 'underscore': '1.3.1' },
- 'underscore dependency should specify exactly 1.3.1'
- )
-
- t.end()
- }
- )
-})
-
-test('\'npm install --save-dev --save-exact\' should install local pkg', function (t) {
- setup()
+const setup = t => {
+ t.test('destroy', t => rimraf(pkg, t.end))
+ t.test('create', t => {
+ mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(json, null, 2)
+ )
+ t.end()
+ })
+ t.end()
+}
+const check = (savearg, deptype) => t => {
common.npm(
[
'--loglevel', 'silent',
'--registry', common.registry,
- '--save-dev',
+ savearg,
'--save-exact',
'install', 'underscore@1.3.1'
],
@@ -82,7 +59,7 @@ test('\'npm install --save-dev --save-exact\' should install local pkg', functio
var pkgJson = JSON.parse(fs.readFileSync(p, 'utf8'))
t.same(
- pkgJson.devDependencies,
+ pkgJson[deptype],
{ 'underscore': '1.3.1' },
'underscore dependency should specify exactly 1.3.1'
)
@@ -90,25 +67,16 @@ test('\'npm install --save-dev --save-exact\' should install local pkg', functio
t.end()
}
)
-})
+}
-test('cleanup', function (t) {
- server.close()
- cleanup()
+test('\'npm install --save --save-exact\' should install local pkg', function (t) {
+ t.test('setup', setup)
+ t.test('check', check('--save', 'dependencies'))
t.end()
})
-function cleanup () {
- process.chdir(osenv.tmpdir())
- rimraf.sync(pkg)
-}
-
-function setup () {
- cleanup()
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
- fs.writeFileSync(
- path.join(pkg, 'package.json'),
- JSON.stringify(json, null, 2)
- )
- process.chdir(pkg)
-}
+test('\'npm install --save-dev --save-exact\' should install local pkg', function (t) {
+ t.test('setup', setup)
+ t.test('check', check('--save-dev', 'devDependencies'))
+ t.end()
+})