flatten.test.ts 606 B

12345678910111213141516171819202122
  1. import flatten from 'app/core/utils/flatten';
  2. describe('flatten', () => {
  3. it('should return flatten object', () => {
  4. const flattened = flatten(
  5. {
  6. level1: 'level1-value',
  7. deeper: {
  8. level2: 'level2-value',
  9. deeper: {
  10. level3: 'level3-value',
  11. },
  12. },
  13. },
  14. null as unknown as { delimiter?: any; maxDepth?: any; safe?: any }
  15. );
  16. expect(flattened['level1']).toBe('level1-value');
  17. expect(flattened['deeper.level2']).toBe('level2-value');
  18. expect(flattened['deeper.deeper.level3']).toBe('level3-value');
  19. });
  20. });