IdentifiersPrefixSanitizer.spec.ts 2.4 KB

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