|
|
|
@ -46,11 +46,16 @@ const multiSeriesWithSingleField = [ |
|
|
|
|
}), |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
let spyConsoleWarn: jest.SpyInstance; |
|
|
|
|
describe('FilterByValue transformer', () => { |
|
|
|
|
beforeAll(() => { |
|
|
|
|
mockTransformationsRegistry([filterByValueTransformer]); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
|
spyConsoleWarn = jest.spyOn(console, 'warn').mockImplementation(() => {}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should exclude values', async () => { |
|
|
|
|
const lower: MatcherConfig<BasicValueMatcherOptions<number>> = { |
|
|
|
|
id: ValueMatcherID.lower, |
|
|
|
@ -92,7 +97,7 @@ describe('FilterByValue transformer', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should not cross frame boundaries', async () => { |
|
|
|
|
it('should not cross frame boundaries when equals 0', async () => { |
|
|
|
|
const cfg: DataTransformerConfig<FilterByValueTransformerOptions> = { |
|
|
|
|
id: DataTransformerID.filterByValue, |
|
|
|
|
options: { |
|
|
|
@ -151,6 +156,66 @@ describe('FilterByValue transformer', () => { |
|
|
|
|
state: {}, |
|
|
|
|
}, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
expect(console.warn).toHaveBeenCalledTimes(2); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
spyConsoleWarn.mockRestore(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should not cross frame boundaries', async () => { |
|
|
|
|
const cfg: DataTransformerConfig<FilterByValueTransformerOptions> = { |
|
|
|
|
id: DataTransformerID.filterByValue, |
|
|
|
|
options: { |
|
|
|
|
type: FilterByValueType.exclude, |
|
|
|
|
match: FilterByValueMatch.any, |
|
|
|
|
filters: [ |
|
|
|
|
{ |
|
|
|
|
fieldName: 'A value', |
|
|
|
|
config: { |
|
|
|
|
id: ValueMatcherID.greater, |
|
|
|
|
options: { value: 0 }, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
await expect(transformDataFrame([cfg], multiSeriesWithSingleField)).toEmitValuesWith((received) => { |
|
|
|
|
const processed = received[0]; |
|
|
|
|
expect(processed.length).toEqual(2); |
|
|
|
|
|
|
|
|
|
expect(processed[0].fields).toEqual([ |
|
|
|
|
{ |
|
|
|
|
name: 'time', |
|
|
|
|
type: FieldType.time, |
|
|
|
|
values: [2000], |
|
|
|
|
state: {}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: 'value', |
|
|
|
|
type: FieldType.number, |
|
|
|
|
values: [0], |
|
|
|
|
state: {}, |
|
|
|
|
}, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
expect(processed[1].fields).toEqual([ |
|
|
|
|
{ |
|
|
|
|
name: 'time', |
|
|
|
|
type: FieldType.time, |
|
|
|
|
values: [5000, 6000, 7000], |
|
|
|
|
state: {}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: 'value', |
|
|
|
|
type: FieldType.number, |
|
|
|
|
values: [0, 1, 1], |
|
|
|
|
state: {}, |
|
|
|
|
}, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
expect(console.warn).toHaveBeenCalledTimes(1); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|