grafana/public/app/plugins/datasource/elasticsearch/utils.test.ts
Gábor Farkas 0cff917f2a
Elasticsearch: Removed reference to obsolete esVersion value (#65415)
* elastic: removed reference to obsolete esVersion value

* removed unused code

* cleaned up tests
2023-03-28 17:04:56 +03:00

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);
});
});