-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Aaron Caldwell
authored
Jun 14, 2021
1 parent
a09d71d
commit ad6c40a
Showing
3 changed files
with
277 additions
and
7 deletions.
There are no files selected for viewing
171 changes: 171 additions & 0 deletions
171
...eo_containment/query_builder/expressions/__snapshots__/entity_by_expression.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
...ublic/alert_types/geo_containment/query_builder/expressions/entity_by_expression.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { EntityByExpression, getValidIndexPatternFields } from './entity_by_expression'; | ||
|
||
const defaultProps = { | ||
errors: { | ||
index: [], | ||
indexId: [], | ||
geoField: [], | ||
entity: [], | ||
dateField: [], | ||
boundaryType: [], | ||
boundaryIndexTitle: [], | ||
boundaryIndexId: [], | ||
boundaryGeoField: [], | ||
name: ['Name is required.'], | ||
interval: [], | ||
alertTypeId: [], | ||
actionConnectors: [], | ||
}, | ||
entity: 'FlightNum', | ||
setAlertParamsEntity: (arg: string) => {}, | ||
indexFields: [ | ||
{ | ||
count: 0, | ||
name: 'DestLocation', | ||
type: 'geo_point', | ||
esTypes: ['geo_point'], | ||
scripted: false, | ||
searchable: true, | ||
aggregatable: true, | ||
readFromDocValues: true, | ||
}, | ||
{ | ||
count: 0, | ||
name: 'FlightNum', | ||
type: 'string', | ||
esTypes: ['keyword'], | ||
scripted: false, | ||
searchable: true, | ||
aggregatable: true, | ||
readFromDocValues: true, | ||
}, | ||
{ | ||
count: 0, | ||
name: 'OriginLocation', | ||
type: 'geo_point', | ||
esTypes: ['geo_point'], | ||
scripted: false, | ||
searchable: true, | ||
aggregatable: true, | ||
readFromDocValues: true, | ||
}, | ||
{ | ||
count: 0, | ||
name: 'timestamp', | ||
type: 'date', | ||
esTypes: ['date'], | ||
scripted: false, | ||
searchable: true, | ||
aggregatable: true, | ||
readFromDocValues: true, | ||
}, | ||
], | ||
isInvalid: false, | ||
}; | ||
|
||
test('should render entity by expression with aggregatable field options for entity', async () => { | ||
const component = mount(<EntityByExpression {...defaultProps} />); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
// | ||
|
||
test('should only use valid index fields', async () => { | ||
// Only the string index field should match | ||
const indexFields = getValidIndexPatternFields(defaultProps.indexFields); | ||
expect(indexFields.length).toEqual(1); | ||
|
||
// Set all agg fields to false, invalidating them for use | ||
const invalidIndexFields = defaultProps.indexFields.map((field) => ({ | ||
...field, | ||
aggregatable: false, | ||
})); | ||
|
||
const noIndexFields = getValidIndexPatternFields(invalidIndexFields); | ||
expect(noIndexFields.length).toEqual(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters