dash.js 658 B

12345678910111213141516171819202122232425262728293031
  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. }