Skip to content

Commit c89d31a

Browse files
elidoranothiym23
authored andcommitted
test: choose test path based on platform
Credit: @elidoran Reviewed-By: @othiym23 PR-URL: #77
1 parent 934943d commit c89d31a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/basic.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,26 @@ test("Empty String results in empty string, not true", function (t) {
1515
t.end()
1616
})
1717

18-
test("~ path is resolved to $HOME", function (t) {
18+
test("~ path is resolved to " + (isWin ? '%USERPROFILE%' : '$HOME'), function (t) {
1919
var path = require("path")
20-
if (!process.env.HOME) process.env.HOME = "/tmp"
21-
var parsed = nopt({key: path}, {}, ["--key=~/val"], 0)
22-
t.same(parsed.key, path.resolve(process.env.HOME, "val"))
20+
, the
21+
22+
if (isWin) {
23+
the = {
24+
key: 'USERPROFILE',
25+
dir: 'C:\\temp',
26+
val: '~\\val'
27+
}
28+
} else {
29+
the = {
30+
key: 'HOME',
31+
dir: '/tmp',
32+
val: '~/val'
33+
}
34+
}
35+
if (!process.env[the.key]) process.env[the.key] = v.dir
36+
var parsed = nopt({key: path}, {}, ["--key=" + the.val], 0)
37+
t.same(parsed.key, path.resolve(process.env[the.key], "val"))
2338
t.end()
2439
})
2540

0 commit comments

Comments
 (0)