diff options
author | isaacs <i@izs.me> | 2013-08-16 08:19:31 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-08-16 08:19:31 -0700 |
commit | 5abdef790c5b9ea5d8424289bf026b3e422ccf7e (patch) | |
tree | 41492416586549b98933414309f8835c59170378 /deps/npm/test/tap/noargs-install-config-save.js | |
parent | f55aca65154e7df01f4bfd1809f200844673f6d4 (diff) | |
download | node-new-5abdef790c5b9ea5d8424289bf026b3e422ccf7e.tar.gz |
npm: Upgrade to 1.3.8
Diffstat (limited to 'deps/npm/test/tap/noargs-install-config-save.js')
-rw-r--r-- | deps/npm/test/tap/noargs-install-config-save.js | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/deps/npm/test/tap/noargs-install-config-save.js b/deps/npm/test/tap/noargs-install-config-save.js index 840caf9f5c..b7bf3a35f9 100644 --- a/deps/npm/test/tap/noargs-install-config-save.js +++ b/deps/npm/test/tap/noargs-install-config-save.js @@ -2,28 +2,29 @@ var test = require("tap").test var npm = require.resolve("../../bin/npm-cli.js") var osenv = require("osenv") var path = require("path") -var http = require("http") var fs = require("fs") var rimraf = require("rimraf") -var mkdirp = require('mkdirp') +var mkdirp = require("mkdirp") -var server, child +var mr = require("npm-registry-mock") + +var child var spawn = require("child_process").spawn var node = process.execPath -var pkg = process.env.npm_config_tmp || '/tmp' -pkg += path.sep + 'noargs-install-config-save' +var pkg = process.env.npm_config_tmp || "/tmp" +pkg += path.sep + "noargs-install-config-save" function writePackageJson() { rimraf.sync(pkg) mkdirp.sync(pkg) - fs.writeFileSync(pkg + '/package.json', JSON.stringify({ + fs.writeFileSync(pkg + "/package.json", JSON.stringify({ "author": "Rocko Artischocko", "name": "noargs", "version": "0.0.0", "devDependencies": { - "underscore": "1.3.0" + "underscore": "1.3.1" } }), 'utf8') } @@ -50,37 +51,29 @@ function createChild (args) { test("does not update the package.json with empty arguments", function (t) { writePackageJson() t.plan(1) - server = http.createServer(function (req, res) { - res.setHeader("content-type", "application/javascript") - res.statusCode = 200 - res.end(JSON.stringify(require("./fixtures/underscore-1-3-3.json"))) + + mr(1337, function (s) { + var child = createChild([npm, "install"]) child.on("close", function (m) { var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8")) t.ok(text.indexOf('"dependencies') === -1) + s.close() t.end() }) - this.close() - }) - server.listen(1337, function() { - child = createChild([npm, "install"]) }) }) test("updates the package.json (adds dependencies) with an argument", function (t) { writePackageJson() t.plan(1) - server = http.createServer(function (req, res) { - res.setHeader("content-type", "application/javascript") - res.statusCode = 200 - res.end(JSON.stringify(require("./fixtures/underscore.json"))) + + mr(1337, function (s) { + var child = createChild([npm, "install", "underscore"]) child.on("close", function (m) { var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8")) t.ok(text.indexOf('"dependencies') !== -1) + s.close() t.end() }) - this.close() - }) - server.listen(1337, function () { - child = createChild([npm, "install", "underscore"]) }) -}) +})
\ No newline at end of file |