node/deps/npm/test/tap/uninstall-package.js

42 lines
958 B
JavaScript
Raw Normal View History

2013-10-25 00:21:59 +08:00
var test = require("tap").test
, npm = require("../../")
2013-11-21 03:08:52 +08:00
, rimraf = require("rimraf")
, mr = require("npm-registry-mock")
, common = require("../common-tap.js")
, pkg = __dirname + "/uninstall-package"
2013-10-25 00:21:59 +08:00
test("returns a list of removed items", function (t) {
t.plan(1)
2013-11-21 03:08:52 +08:00
mr(common.port, function (s) {
setup(function () {
npm.install(".", function (err) {
2013-10-25 00:21:59 +08:00
if (err) return t.fail(err)
2013-11-21 03:08:52 +08:00
npm.uninstall("underscore", "request", "lala", function (err, d) {
if (err) return t.fail(err)
t.same(d.sort(), ["underscore", "request"].sort())
s.close()
t.end()
})
2013-10-25 00:21:59 +08:00
})
})
})
})
2013-11-21 03:08:52 +08:00
test("cleanup", function (t) {
cleanup()
t.end()
})
2013-10-25 00:21:59 +08:00
function setup (cb) {
2013-11-21 03:08:52 +08:00
cleanup()
process.chdir(pkg)
npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
2013-10-25 00:21:59 +08:00
cb()
})
}
2013-11-21 03:08:52 +08:00
function cleanup () {
rimraf.sync(pkg + "/node_modules")
rimraf.sync(pkg + "/cache")
}