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.

31 lines
658 B

7 years ago
  1. var optimist = require('../index');
  2. var test = require('tap').test;
  3. test('-', function (t) {
  4. t.plan(5);
  5. t.deepEqual(
  6. fix(optimist.parse([ '-n', '-' ])),
  7. { n: '-', _: [] }
  8. );
  9. t.deepEqual(
  10. fix(optimist.parse([ '-' ])),
  11. { _: [ '-' ] }
  12. );
  13. t.deepEqual(
  14. fix(optimist.parse([ '-f-' ])),
  15. { f: '-', _: [] }
  16. );
  17. t.deepEqual(
  18. fix(optimist([ '-b', '-' ]).boolean('b').argv),
  19. { b: true, _: [ '-' ] }
  20. );
  21. t.deepEqual(
  22. fix(optimist([ '-s', '-' ]).string('s').argv),
  23. { s: '-', _: [] }
  24. );
  25. });
  26. function fix (obj) {
  27. delete obj.$0;
  28. return obj;
  29. }