The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/influxdb/components/InfluxLogsQueryField.test.tsx

53 lines
1.1 KiB

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);
});
});
});