mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -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: [
|
||||
{
|
||||
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();
|
||||
});
|
||||
|
||||
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', () => {
|
||||
@ -43,7 +51,7 @@ describe('value not null matcher', () => {
|
||||
fields: [
|
||||
{
|
||||
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();
|
||||
});
|
||||
|
||||
it('should match non-null values', () => {
|
||||
it('should not match null values', () => {
|
||||
const frame = data[0];
|
||||
const field = frame.fields[0];
|
||||
const valueIndex = 1;
|
||||
|
||||
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: () => {
|
||||
return (valueIndex: number, field: Field) => {
|
||||
const value = field.values.get(valueIndex);
|
||||
return value === null;
|
||||
return value == null;
|
||||
};
|
||||
},
|
||||
getOptionsDisplayText: () => {
|
||||
@ -27,7 +27,7 @@ const isNotNullValueMatcher: ValueMatcherInfo<ValueMatcherOptions> = {
|
||||
get: () => {
|
||||
return (valueIndex: number, field: Field) => {
|
||||
const value = field.values.get(valueIndex);
|
||||
return value !== null;
|
||||
return value != null;
|
||||
};
|
||||
},
|
||||
getOptionsDisplayText: () => {
|
||||
|
Loading…
Reference in New Issue
Block a user