-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add jest test for IncompleteResultsModal component
- Loading branch information
Showing
3 changed files
with
340 additions
and
1 deletion.
There are no files selected for viewing
271 changes: 271 additions & 0 deletions
271
...data/public/incomplete_results_modal/__snapshots__/incomplete_results_modal.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.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,68 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; | ||
import type { SearchResponseIncompleteWarning } from '../search'; | ||
import { IncompleteResultsModal } from './incomplete_results_modal'; | ||
|
||
describe('IncompleteResultsModal', () => { | ||
test('should render shard failures', () => { | ||
const component = shallow( | ||
<IncompleteResultsModal | ||
warning={{} as unknown as SearchResponseIncompleteWarning} | ||
request={{}} | ||
response={{ | ||
_shards: { | ||
total: 4, | ||
successful: 3, | ||
skipped: 0, | ||
failed: 1, | ||
failures: [ | ||
{ | ||
shard: 0, | ||
index: 'sample-01-rollup', | ||
node: 'VFTFJxpHSdaoiGxJFLSExQ', | ||
reason: { | ||
type: 'illegal_argument_exception', | ||
reason: | ||
'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', | ||
}, | ||
}, | ||
], | ||
}, | ||
}as unknown as estypes.SearchResponse<any>} | ||
onClose={jest.fn()} | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
test('should render time out', () => { | ||
const component = shallow( | ||
<IncompleteResultsModal | ||
warning={{} as unknown as SearchResponseIncompleteWarning} | ||
request={{}} | ||
response={{ | ||
timed_out: true, | ||
_shards: { | ||
total: 4, | ||
successful: 4, | ||
skipped: 0, | ||
failed: 0, | ||
}, | ||
} as unknown as estypes.SearchResponse<any>} | ||
onClose={jest.fn()} | ||
/> | ||
); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
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