BooleanSanitizer.spec.ts 1.9 KB

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