Skip to content

Commit

Permalink
passing tests for new .default() behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Dec 1, 2010
1 parent 932725e commit cd7f8c5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,42 @@ exports.countFail = function (assert) {
});
};

exports.defaultSingles = function (assert) {
var r = checkUsage(function () {
return optimist('--foo 50 --baz 70 --powsy'.split(' '))
.default('foo', 5)
.default('bar', 6)
.default('baz', 7)
.argv
;
});
assert.eql(r.result, {
foo : '50',
bar : 6,
baz : '70',
powsy : true,
_ : [],
$0 : './usage',
});
};

exports.defaultHash = function (assert) {
var r = checkUsage(function () {
return optimist('--foo 50 --baz 70'.split(' '))
.default({ foo : 10, bar : 20, quux : 30 })
.argv
;
});
assert.eql(r.result, {
foo : '50',
bar : 20,
baz : 70,
quux : 30,
_ : [],
$0 : './usage',
});
};

exports.rebase = function (assert) {
assert.equal(
optimist.rebase('/home/substack', '/home/substack/foo/bar/baz'),
Expand Down

0 comments on commit cd7f8c5

Please sign in to comment.