mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Explore: Runs query when measurement/field and pairs are select in logs mode for influx Closes #17500 * Explore: Modifies logic determining when to auto-run query during influx logs mode Also adds test to validate this logic
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { pairsAreValid } from './InfluxLogsQueryField';
|
|
|
|
describe('pairsAreValid()', () => {
|
|
describe('when all pairs are fully defined', () => {
|
|
it('should return true', () => {
|
|
const pairs = [
|
|
{
|
|
key: 'a',
|
|
operator: '=',
|
|
value: '1',
|
|
},
|
|
{
|
|
key: 'b',
|
|
operator: '!=',
|
|
value: '2',
|
|
},
|
|
];
|
|
|
|
expect(pairsAreValid(pairs as any)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('when no pairs are defined at all', () => {
|
|
it('should return true', () => {
|
|
expect(pairsAreValid([])).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('when pairs are undefined', () => {
|
|
it('should return true', () => {
|
|
expect(pairsAreValid(undefined)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('when one or more pairs are only partially defined', () => {
|
|
it('should return false', () => {
|
|
const pairs = [
|
|
{
|
|
key: 'a',
|
|
operator: undefined,
|
|
value: '1',
|
|
},
|
|
{
|
|
key: 'b',
|
|
operator: '!=',
|
|
value: '2',
|
|
},
|
|
];
|
|
|
|
expect(pairsAreValid(pairs as any)).toBe(false);
|
|
});
|
|
});
|
|
});
|