ArraySanitizer.spec.ts 1.2 KB

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