kv_short.js 660 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. var parse = require('../');
  3. var test = require('tape');
  4. test('short -k=v', function (t) {
  5. t.plan(1);
  6. var argv = parse(['-b=123']);
  7. t.deepEqual(argv, { b: 123, _: [] });
  8. });
  9. test('multi short -k=v', function (t) {
  10. t.plan(1);
  11. var argv = parse(['-a=whatever', '-b=robots']);
  12. t.deepEqual(argv, { a: 'whatever', b: 'robots', _: [] });
  13. });
  14. test('short with embedded equals -k=a=b', function (t) {
  15. t.plan(1);
  16. var argv = parse(['-k=a=b']);
  17. t.deepEqual(argv, { k: 'a=b', _: [] });
  18. });
  19. test('short with later equals like -ab=c', function (t) {
  20. t.plan(1);
  21. var argv = parse(['-ab=c']);
  22. t.deepEqual(argv, { a: true, b: 'c', _: [] });
  23. });