@@ -11,6 +11,8 @@ import { ElasticsearchQuery, MetricAggregationType, BucketAggregationType } from
11
11
import { useFields } from './useFields' ;
12
12
import { renderHook } from '@testing-library/react-hooks' ;
13
13
14
+
15
+
14
16
describe ( 'useFields hook' , ( ) => {
15
17
// TODO: If we move the field type to the configuration objects as described in the hook's source
16
18
// we can stop testing for getField to be called with the correct parameters.
@@ -48,39 +50,39 @@ describe('useFields hook', () => {
48
50
{ wrapper, initialProps : 'cardinality' }
49
51
) ;
50
52
result . current ( ) ;
51
- expect ( getFields ) . toHaveBeenLastCalledWith ( true , [ ] , timeRange ) ;
53
+ expect ( getFields ) . toHaveBeenLastCalledWith ( { aggregatable : true , type : [ ] , _range : timeRange } ) ;
52
54
53
55
// All other metric aggregations only work on numbers
54
56
rerender ( 'avg' ) ;
55
57
result . current ( ) ;
56
- expect ( getFields ) . toHaveBeenLastCalledWith ( true , [ 'number' ] , timeRange ) ;
58
+ expect ( getFields ) . toHaveBeenLastCalledWith ( { aggregatable : true , type : [ 'number' ] , _range : timeRange } ) ;
57
59
58
60
//
59
61
// BUCKET AGGREGATIONS
60
62
//
61
63
// Date Histrogram only works on dates
62
64
rerender ( 'date_histogram' ) ;
63
65
result . current ( ) ;
64
- expect ( getFields ) . toHaveBeenLastCalledWith ( true , [ 'date' ] , timeRange ) ;
66
+ expect ( getFields ) . toHaveBeenLastCalledWith ( { aggregatable : true , type : [ 'date' ] , _range : timeRange } ) ;
65
67
66
68
// Histrogram only works on numbers
67
69
rerender ( 'histogram' ) ;
68
70
result . current ( ) ;
69
- expect ( getFields ) . toHaveBeenLastCalledWith ( true , [ 'number' ] , timeRange ) ;
71
+ expect ( getFields ) . toHaveBeenLastCalledWith ( { aggregatable : true , type : [ 'number' ] , _range : timeRange } ) ;
70
72
71
73
// Geohash Grid only works on geo_point data
72
74
rerender ( 'geohash_grid' ) ;
73
75
result . current ( ) ;
74
- expect ( getFields ) . toHaveBeenLastCalledWith ( true , [ 'geo_point' ] , timeRange ) ;
76
+ expect ( getFields ) . toHaveBeenLastCalledWith ( { aggregatable : true , type : [ 'geo_point' ] , _range : timeRange } ) ;
75
77
76
78
// All other bucket aggregation work on any kind of data
77
79
rerender ( 'terms' ) ;
78
80
result . current ( ) ;
79
- expect ( getFields ) . toHaveBeenLastCalledWith ( true , [ ] , timeRange ) ;
81
+ expect ( getFields ) . toHaveBeenLastCalledWith ( { aggregatable : true , type : [ ] , _range : timeRange } ) ;
80
82
81
83
// top_metrics work on only on numeric data in 7.7
82
84
rerender ( 'top_metrics' ) ;
83
85
result . current ( ) ;
84
- expect ( getFields ) . toHaveBeenLastCalledWith ( true , [ 'number' ] , timeRange ) ;
86
+ expect ( getFields ) . toHaveBeenLastCalledWith ( { aggregatable : true , type : [ 'number' ] , _range : timeRange } ) ;
85
87
} ) ;
86
88
} ) ;
0 commit comments