ArraySanitizer.spec.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { assert } from 'chai';
  2. import { ArraySanitizer } from '../../../../src/cli/sanitizers/ArraySanitizer';
  3. describe('ArraySanitizer', () => {
  4. describe('ArraySanitizer: TCLISanitizer = (value: string): string[]', () => {
  5. describe('Variant #1: input value `foo`', () => {
  6. const inputValue: string = 'foo';
  7. const expectedValue: string[] = ['foo'];
  8. let value: string[];
  9. before(() => {
  10. value = ArraySanitizer(inputValue);
  11. });
  12. it('should sanitize value', () => {
  13. assert.deepEqual(value, expectedValue);
  14. });
  15. });
  16. describe('Variant #2: input value `foo, bar`', () => {
  17. const inputValue: string = 'foo, bar';
  18. const expectedValue: string[] = ['foo', 'bar'];
  19. let value: string[];
  20. before(() => {
  21. value = ArraySanitizer(inputValue);
  22. });
  23. it('should sanitize value', () => {
  24. assert.deepEqual(value, expectedValue);
  25. });
  26. });
  27. describe('Variant #3: input value `foo,`', () => {
  28. const inputValue: string = 'foo,';
  29. const testFunc: () => void = () => {
  30. ArraySanitizer(inputValue);
  31. };
  32. it('should sanitize value', () => {
  33. assert.throw(testFunc, SyntaxError);
  34. });
  35. });
  36. });
  37. });