This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add link and link-install test
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |