BooleanSanitizer.spec.ts 1.6 KB

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