You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
778 B

7 years ago
  1. var test = require('tape');
  2. var parse = require('../');
  3. test('boolean default true', function (t) {
  4. var argv = parse([], {
  5. boolean: 'sometrue',
  6. default: { sometrue: true }
  7. });
  8. t.equal(argv.sometrue, true);
  9. t.end();
  10. });
  11. test('boolean default false', function (t) {
  12. var argv = parse([], {
  13. boolean: 'somefalse',
  14. default: { somefalse: false }
  15. });
  16. t.equal(argv.somefalse, false);
  17. t.end();
  18. });
  19. test('boolean default to null', function (t) {
  20. var argv = parse([], {
  21. boolean: 'maybe',
  22. default: { maybe: null }
  23. });
  24. t.equal(argv.maybe, null);
  25. var argv = parse(['--maybe'], {
  26. boolean: 'maybe',
  27. default: { maybe: null }
  28. });
  29. t.equal(argv.maybe, true);
  30. t.end();
  31. })