Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15615 from apalumbo/next
Trailing comma handling for "-s" command line paramenter
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { parseList } from '../utils'; | ||
|
||
describe('parseList', () => { | ||
test.each` | ||
source | expected | ||
${'item1,item2, item3'} | ${['item1', 'item2', 'item3']} | ||
${'item1 , item2, item3 '} | ${['item1', 'item2', 'item3']} | ||
`(`Items will be trimmed, source "$source" should return $expected`, ({ source, expected }) => { | ||
const result = parseList(source); | ||
expect(result).toEqual(expected); | ||
}); | ||
|
||
test.each` | ||
source | expected | ||
${'item1,item2, '} | ${['item1', 'item2']} | ||
${'item1, ,item3 '} | ${['item1', 'item3']} | ||
${'item1,,item3 '} | ${['item1', 'item3']} | ||
${'item1,, '} | ${['item1']} | ||
`( | ||
`Empty items will be stripped, source "$source" should return $expected`, | ||
({ source, expected }) => { | ||
const result = parseList(source); | ||
expect(result).toEqual(expected); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters