mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 05:43:19 +08:00
Elasticsearch: Migrate queryeditor to React (#28033)
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
36
public/app/plugins/datasource/elasticsearch/utils.test.ts
Normal file
36
public/app/plugins/datasource/elasticsearch/utils.test.ts
Normal file
@ -0,0 +1,36 @@
|
||||
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);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user