Skip to content

Commit

Permalink
command line: add test for -v --version flags
Browse files Browse the repository at this point in the history
for #94
  • Loading branch information
feross committed Sep 17, 2014
1 parent eb0321e commit 3dde524
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
1 change: 0 additions & 1 deletion bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ function remove (cb) {

var torrent = client.add(torrentId)


torrent.on('infoHash', function () {
function updateMetadata () {
var numPeers = torrent.swarm.numPeers
Expand Down
25 changes: 22 additions & 3 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,29 @@ test('Module usage (sanity check)', function (t) {
})
})

test('Command line usage (sanity check)', function (t) {
test('Command line: --help', function (t) {
t.plan(2)

var bin = __dirname + '/../bin/cmd.js --help'
cp.exec(bin, function (err) {
cp.exec(bin, function (err, data) {
t.error(err) // no error, exit code 0
t.end()
t.ok(data.indexOf('usage') !== 0)
})
})

test('Command line: -v --version', function (t) {
t.plan(4)
var expectedVersion = require(__dirname + '/../package.json').version + '\n'

var bin = __dirname + '/../bin/cmd.js --version'
cp.exec(bin, function (err, data) {
t.error(err) // no error, exit code 0
t.equal(data, expectedVersion)
})

bin = __dirname + '/../bin/cmd.js -v'
cp.exec(bin, function (err, data) {
t.error(err) // no error, exit code 0
t.equal(data, expectedVersion)
})
})

0 comments on commit 3dde524

Please sign in to comment.