Skip to content

Commit

Permalink
test: choose test path based on platform
Browse files Browse the repository at this point in the history
Credit: @elidoran
Reviewed-By: @othiym23
PR-URL: #77
  • Loading branch information
elidoran authored and othiym23 committed Dec 13, 2016
1 parent 934943d commit c89d31a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,26 @@ test("Empty String results in empty string, not true", function (t) {
t.end()
})

test("~ path is resolved to $HOME", function (t) {
test("~ path is resolved to " + (isWin ? '%USERPROFILE%' : '$HOME'), function (t) {
var path = require("path")
if (!process.env.HOME) process.env.HOME = "/tmp"
var parsed = nopt({key: path}, {}, ["--key=~/val"], 0)
t.same(parsed.key, path.resolve(process.env.HOME, "val"))
, the

if (isWin) {
the = {
key: 'USERPROFILE',
dir: 'C:\\temp',
val: '~\\val'
}
} else {
the = {
key: 'HOME',
dir: '/tmp',
val: '~/val'
}
}
if (!process.env[the.key]) process.env[the.key] = v.dir
var parsed = nopt({key: path}, {}, ["--key=" + the.val], 0)
t.same(parsed.key, path.resolve(process.env[the.key], "val"))
t.end()
})

Expand Down

0 comments on commit c89d31a

Please sign in to comment.