UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

59 lines (49 loc) 1.11 kB
import { replaceUndefinedValuesWithNull } from './replaceUndefinedValuesWithNull'; describe('replaceUndefinedValuesWithNull', () => { it('should replace all undefined values with null', () => { const obj = { a: undefined, b: { c: undefined, d: 'hello' }, e: null }; const expected = { a: null, b: { c: null, d: 'hello' }, e: null }; const result = replaceUndefinedValuesWithNull(obj); expect(result).toEqual(expected); }); it('should not modify objects with no undefined values', () => { const obj = { a: 1, b: { c: 2, d: 'hello' }, e: null }; const expected = { a: 1, b: { c: 2, d: 'hello' }, e: null }; const result = replaceUndefinedValuesWithNull(obj); expect(result).toEqual(expected); }); it('should handle empty objects', () => { const obj = {}; const expected = {}; const result = replaceUndefinedValuesWithNull(obj); expect(result).toEqual(expected); }); });