D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
alerting
/
unified
/
utils
/
Filename :
receiver-form.test.ts
back
Copy
import { omitEmptyValues, omitEmptyUnlessExisting } from './receiver-form'; describe('Receiver form utils', () => { describe('omitEmptyStringValues', () => { it('should recursively omit empty strings but leave other properties in palce', () => { const original = { one: 'two', remove: '', three: 0, four: null, five: [ [ { foo: 'bar', remove: '', notDefined: undefined, }, ], { foo: 'bar', remove: '', }, ], }; const expected = { one: 'two', three: 0, five: [ [ { foo: 'bar', }, ], { foo: 'bar', }, ], }; expect(omitEmptyValues(original)).toEqual(expected); }); }); describe('omitEmptyUnlessExisting', () => { it('should omit empty strings if no entry in existing', () => { const existing = { five_keep: true, }; const original = { one: 'two', two_remove: '', three: 0, four_remove: null, five_keep: '', }; const expected = { one: 'two', three: 0, five_keep: '', }; expect(omitEmptyUnlessExisting(original, existing)).toEqual(expected); }); }); });