mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
37 lines
986 B
TypeScript
37 lines
986 B
TypeScript
import { removeEmpty } from './utils';
|
|
|
|
describe('removeEmpty', () => {
|
|
it('Should remove all empty', () => {
|
|
const original = {
|
|
stringsShouldBeKept: 'Something',
|
|
unlessTheyAreEmpty: '',
|
|
nullToBeRemoved: null,
|
|
undefinedToBeRemoved: null,
|
|
zeroShouldBeKept: 0,
|
|
booleansShouldBeKept: false,
|
|
emptyObjectsShouldBeRemoved: {},
|
|
emptyArrayShouldBeRemoved: [],
|
|
nonEmptyArraysShouldBeKept: [1, 2, 3],
|
|
nestedObjToBeRemoved: {
|
|
toBeRemoved: undefined,
|
|
},
|
|
nestedObjectToKeep: {
|
|
thisShouldBeRemoved: null,
|
|
thisShouldBeKept: 'Hello, Grafana',
|
|
},
|
|
};
|
|
|
|
const expectedResult = {
|
|
stringsShouldBeKept: 'Something',
|
|
zeroShouldBeKept: 0,
|
|
booleansShouldBeKept: false,
|
|
nonEmptyArraysShouldBeKept: [1, 2, 3],
|
|
nestedObjectToKeep: {
|
|
thisShouldBeKept: 'Hello, Grafana',
|
|
},
|
|
};
|
|
|
|
expect(removeEmpty(original)).toStrictEqual(expectedResult);
|
|
});
|
|
});
|