diff --git a/packages/grafana-data/src/transformations/matchers/valueMatchers/nullMatchers.test.ts b/packages/grafana-data/src/transformations/matchers/valueMatchers/nullMatchers.test.ts index 91b1f06bf49..ce2c0702190 100644 --- a/packages/grafana-data/src/transformations/matchers/valueMatchers/nullMatchers.test.ts +++ b/packages/grafana-data/src/transformations/matchers/valueMatchers/nullMatchers.test.ts @@ -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(); + }); }); diff --git a/packages/grafana-data/src/transformations/matchers/valueMatchers/nullMatchers.ts b/packages/grafana-data/src/transformations/matchers/valueMatchers/nullMatchers.ts index 42ce8b142bf..e3f19a68d97 100644 --- a/packages/grafana-data/src/transformations/matchers/valueMatchers/nullMatchers.ts +++ b/packages/grafana-data/src/transformations/matchers/valueMatchers/nullMatchers.ts @@ -10,7 +10,7 @@ const isNullValueMatcher: ValueMatcherInfo = { 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 = { get: () => { return (valueIndex: number, field: Field) => { const value = field.values.get(valueIndex); - return value !== null; + return value != null; }; }, getOptionsDisplayText: () => {