Yuki Takei 7 years ago
parent
commit
1cb44846c7
1 changed files with 14 additions and 4 deletions
  1. 14 4
      packages/growi-commons/src/test/plugin/util/option-parser.test.js

+ 14 - 4
packages/growi-commons/src/test/plugin/util/option-parser.test.js

@@ -15,10 +15,20 @@ describe('option-parser', () => {
     ${'aaa'}
     ${'5++2'}
     ${'5:+2'}
-  `.describe.only('.parseRange(\'$arg\')', ({ arg }) => {
-    test('returns null', () => {
-      expect(OptionParser.parseRange(arg)).toBeNull();
-    });
+  `.test('.parseRange(\'$arg\') returns null', ({ arg }) => {
+    expect(OptionParser.parseRange(arg)).toBeNull();
+  });
+
+  each`
+    arg       | start | end
+    ${'1'}    | ${1} | ${1}
+    ${'2:1'}  | ${2} | ${1}
+    ${'2:'}   | ${2} | ${-1}
+    ${'10:-3'}   | ${10} | ${-3}
+    ${'5+2'}   | ${5} | ${7}
+    ${'5+'}   | ${5} | ${5}
+  `.test('.parseRange(\'$arg\') returns { start: $start, end : $end }', ({ arg, start, end }) => {
+    expect(OptionParser.parseRange(arg)).toEqual({ start, end });
   });
 
 });