StringArrayEncodingSanitizer.spec.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { assert } from 'chai';
  2. import { StringArrayEncodingSanitizer } from '../../../../src/cli/sanitizers/StringArrayEncodingSanitizer';
  3. describe('StringArrayEncodingSanitizer', () => {
  4. describe('StringArrayEncodingSanitizer: TCLISanitizer = (value: string): TStringArrayEncoding', () => {
  5. describe('variant #1: string array encoding `base64`', () => {
  6. const inputValue: string = 'base64';
  7. const expectedValue: boolean = true;
  8. let value: boolean;
  9. before(() => {
  10. value = StringArrayEncodingSanitizer(inputValue);
  11. });
  12. it('should sanitize value', () => {
  13. assert.equal(value, expectedValue);
  14. });
  15. });
  16. describe('variant #2: string array encoding `true`', () => {
  17. const inputValue: string = 'true';
  18. const expectedValue: boolean = true;
  19. let value: boolean;
  20. before(() => {
  21. value = StringArrayEncodingSanitizer(inputValue);
  22. });
  23. it('should sanitize value', () => {
  24. assert.equal(value, expectedValue);
  25. });
  26. });
  27. describe('variant #3: string array encoding `1`', () => {
  28. const inputValue: string = '1';
  29. const expectedValue: boolean = true;
  30. let value: boolean;
  31. before(() => {
  32. value = StringArrayEncodingSanitizer(inputValue);
  33. });
  34. it('should sanitize value', () => {
  35. assert.equal(value, expectedValue);
  36. });
  37. });
  38. describe('variant #4: string array encoding `rc4`', () => {
  39. const inputValue: string = 'rc4';
  40. const expectedValue: string = 'rc4';
  41. let value: string;
  42. before(() => {
  43. value = StringArrayEncodingSanitizer(inputValue);
  44. });
  45. it('should sanitize value', () => {
  46. assert.equal(value, expectedValue);
  47. });
  48. });
  49. describe('variant #5: string array encoding `foo`', () => {
  50. const inputValue: string = 'foo';
  51. const expectedValue: boolean = false;
  52. let value: boolean;
  53. before(() => {
  54. value = StringArrayEncodingSanitizer(inputValue);
  55. });
  56. it('should sanitize value', () => {
  57. assert.equal(value, expectedValue);
  58. });
  59. });
  60. });
  61. });