mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
Matchers: handle undefined with Is/Is not null (#38036)
This commit is contained in:
parent
5edba603a8
commit
d18205ff20
@ -9,7 +9,7 @@ describe('value null matcher', () => {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'temp',
|
name: 'temp',
|
||||||
values: [23, null, 10],
|
values: [23, null, 10, undefined],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@ -35,6 +35,14 @@ describe('value null matcher', () => {
|
|||||||
|
|
||||||
expect(matcher(valueIndex, field, frame, data)).toBeFalsy();
|
expect(matcher(valueIndex, field, frame, data)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should match undefined values', () => {
|
||||||
|
const frame = data[0];
|
||||||
|
const field = frame.fields[0];
|
||||||
|
const valueIndex = 3;
|
||||||
|
|
||||||
|
expect(matcher(valueIndex, field, frame, data)).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('value not null matcher', () => {
|
describe('value not null matcher', () => {
|
||||||
@ -43,7 +51,7 @@ describe('value not null matcher', () => {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'temp',
|
name: 'temp',
|
||||||
values: [23, null, 10],
|
values: [23, null, 10, undefined],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@ -62,11 +70,19 @@ describe('value not null matcher', () => {
|
|||||||
expect(matcher(valueIndex, field, frame, data)).toBeTruthy();
|
expect(matcher(valueIndex, field, frame, data)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should match non-null values', () => {
|
it('should not match null values', () => {
|
||||||
const frame = data[0];
|
const frame = data[0];
|
||||||
const field = frame.fields[0];
|
const field = frame.fields[0];
|
||||||
const valueIndex = 1;
|
const valueIndex = 1;
|
||||||
|
|
||||||
expect(matcher(valueIndex, field, frame, data)).toBeFalsy();
|
expect(matcher(valueIndex, field, frame, data)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not match undefined values', () => {
|
||||||
|
const frame = data[0];
|
||||||
|
const field = frame.fields[0];
|
||||||
|
const valueIndex = 3;
|
||||||
|
|
||||||
|
expect(matcher(valueIndex, field, frame, data)).toBeFalsy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ const isNullValueMatcher: ValueMatcherInfo<ValueMatcherOptions> = {
|
|||||||
get: () => {
|
get: () => {
|
||||||
return (valueIndex: number, field: Field) => {
|
return (valueIndex: number, field: Field) => {
|
||||||
const value = field.values.get(valueIndex);
|
const value = field.values.get(valueIndex);
|
||||||
return value === null;
|
return value == null;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getOptionsDisplayText: () => {
|
getOptionsDisplayText: () => {
|
||||||
@ -27,7 +27,7 @@ const isNotNullValueMatcher: ValueMatcherInfo<ValueMatcherOptions> = {
|
|||||||
get: () => {
|
get: () => {
|
||||||
return (valueIndex: number, field: Field) => {
|
return (valueIndex: number, field: Field) => {
|
||||||
const value = field.values.get(valueIndex);
|
const value = field.values.get(valueIndex);
|
||||||
return value !== null;
|
return value != null;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getOptionsDisplayText: () => {
|
getOptionsDisplayText: () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user