receiver-form.test.ts 890 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { omitEmptyValues } from './receiver-form';
  2. describe('Receiver form utils', () => {
  3. describe('omitEmptyStringValues', () => {
  4. it('should recursively omit empty strings but leave other properties in palce', () => {
  5. const original = {
  6. one: 'two',
  7. remove: '',
  8. three: 0,
  9. four: null,
  10. five: [
  11. [
  12. {
  13. foo: 'bar',
  14. remove: '',
  15. notDefined: undefined,
  16. },
  17. ],
  18. {
  19. foo: 'bar',
  20. remove: '',
  21. },
  22. ],
  23. };
  24. const expected = {
  25. one: 'two',
  26. three: 0,
  27. five: [
  28. [
  29. {
  30. foo: 'bar',
  31. },
  32. ],
  33. {
  34. foo: 'bar',
  35. },
  36. ],
  37. };
  38. expect(omitEmptyValues(original)).toEqual(expected);
  39. });
  40. });
  41. });