From 5811468e104ccb6b26b8715dff390d68daa10066 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Wed, 25 Mar 2015 01:33:01 +0900 Subject: [PATCH] test: add link and link-install test --- test/tap/link-install/package.json | 11 +++++++ test/tap/link.js | 50 ++++++++++++++++++++++++++++++ test/tap/link/package.json | 11 +++++++ 3 files changed, 72 insertions(+) create mode 100644 test/tap/link-install/package.json create mode 100644 test/tap/link.js create mode 100644 test/tap/link/package.json diff --git a/test/tap/link-install/package.json b/test/tap/link-install/package.json new file mode 100644 index 00000000000..64287662101 --- /dev/null +++ b/test/tap/link-install/package.json @@ -0,0 +1,11 @@ +{ + "name": "bar", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/test/tap/link.js b/test/tap/link.js new file mode 100644 index 00000000000..0fa5e8ea29a --- /dev/null +++ b/test/tap/link.js @@ -0,0 +1,50 @@ +var path = require("path") +var test = require("tap").test +var common = require("../common-tap.js") +var link = path.join(__dirname, "link") +var linkInstall = path.join(__dirname, "link-install") + +test("setup", function (t) { + common.npm(["ls", "-g", "--depth=0"], {}, function (err, c, out) { + t.ifError(err) + t.equal(c, 0, "set up ok") + t.notOk(out.match(/UNMET DEPENDENCY foo@/), "foo isn't in global") + t.end() + }) +}); + +test("creates global link", function (t) { + process.chdir(link) + common.npm("link", {}, function (err,c , out) { + t.ifError(err, "link has no error") + common.npm(["ls", "-g"], {}, function (err, c, out) { + t.ifError(err) + t.equal(c, 0) + t.has(out, /foo@1.0.0/, "creates global link ok") + t.end() + }) + }) +}) + +test("link-install the package", function (t) { + process.chdir(linkInstall) + common.npm(["link", "foo"], {}, function (err) { + t.ifError(err, "link-install has no error") + common.npm("ls", {}, function (err, c, out) { + t.ifError(err) + t.equal(c, 1) + t.has(out, /foo@1.0.0/, "link-install ok") + t.end() + }) + }); +}) + +test("cleanup", function (t) { + common.npm(["rm", "foo"], {}, function (err, code) { + t.equal(code, 0, "cleanup foo in local ok") + common.npm(["rm", "-g", "foo"], {}, function (err, code) { + t.equal(code, 0, "cleanup foo in global ok") + t.end() + }) + }) +}) diff --git a/test/tap/link/package.json b/test/tap/link/package.json new file mode 100644 index 00000000000..86bff1375ea --- /dev/null +++ b/test/tap/link/package.json @@ -0,0 +1,11 @@ +{ + "name": "foo", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +}