-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathindex.test.tsx
More file actions
49 lines (41 loc) · 1.39 KB
/
index.test.tsx
File metadata and controls
49 lines (41 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { render, screen } from '@testing-library/react';
import React from 'react';
import { ElasticDatasource } from '@/datasource';
import { ElasticsearchQuery } from '@/types';
import { QueryEditor } from '.';
import { noop } from 'lodash';
describe('QueryEditor', () => {
it('Should NOT show Bucket Aggregations Editor if query contains a "singleMetric" metric', () => {
const query: ElasticsearchQuery = {
refId: 'A',
query: '',
metrics: [
{
id: '1',
type: 'logs',
},
],
// Even if present, this shouldn't be shown in the UI
bucketAggs: [{ id: '2', type: 'date_histogram' }],
filters: [],
};
render(<QueryEditor query={query} datasource={{} as ElasticDatasource} onChange={noop} onRunQuery={noop} />);
expect(screen.queryByLabelText('Group By')).not.toBeInTheDocument();
});
it('Should show Bucket Aggregations Editor if query does NOT contains a "singleMetric" metric', () => {
const query: ElasticsearchQuery = {
refId: 'A',
query: '',
metrics: [
{
id: '1',
type: 'avg',
},
],
bucketAggs: [{ id: '2', type: 'date_histogram' }],
filters: [],
};
render(<QueryEditor query={query} datasource={{} as ElasticDatasource} onChange={noop} onRunQuery={noop} />);
expect(screen.getByText('Group By')).toBeInTheDocument();
});
});