2
0

option-parser.spec.ts 722 B

12345678910111213141516171819202122232425262728
  1. import { describe, test, expect } from 'vitest';
  2. import { OptionParser } from './option-parser';
  3. describe('option-parser', () => {
  4. test.concurrent.each`
  5. arg
  6. ${'aaa'}
  7. ${'5++2'}
  8. ${'5:+2'}
  9. `('.parseRange(\'$arg\') returns null', ({ arg }) => {
  10. expect(OptionParser.parseRange(arg)).toBeNull();
  11. });
  12. test.concurrent.each`
  13. arg | start | end
  14. ${'1'} | ${1} | ${1}
  15. ${'2:1'} | ${2} | ${1}
  16. ${'2:'} | ${2} | ${-1}
  17. ${'10:-3'} | ${10} | ${-3}
  18. ${'5+2'} | ${5} | ${7}
  19. ${'5+'} | ${5} | ${5}
  20. `('.parseRange(\'$arg\') returns { start: $start, end : $end }', ({ arg, start, end }) => {
  21. expect(OptionParser.parseRange(arg)).toEqual({ start, end });
  22. });
  23. });