[AppServices] Fix unhandled promise rejections in search tests (#112849)

* updated jest tests to avoid generating unhandled promise rejections

* rather use throwError

* remove unused imports

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Jean-Louis Leysens 2021-09-28 15:40:13 +02:00 committed by GitHub
parent 47c9efded8
commit 7a49851bc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { of } from 'rxjs';
import { of, throwError } from 'rxjs';
import { IndexPattern } from '../..';
import { SearchSource, SearchSourceDependencies, SortDirection } from './';
import { AggConfigs, AggTypesRegistryStart } from '../../';
@ -1113,7 +1113,7 @@ describe('SearchSource', () => {
},
};
searchSourceDependencies.search = jest.fn().mockReturnValue(of(Promise.reject('aaaaa')));
searchSourceDependencies.search = jest.fn().mockReturnValue(throwError('aaaaa'));
searchSource = new SearchSource({}, searchSourceDependencies);
searchSource.setField('index', indexPattern);

View file

@ -38,10 +38,8 @@ describe('Search service', () => {
let mockCoreStart: MockedKeys<CoreStart>;
beforeEach(() => {
const mockLogger: any = {
debug: () => {},
};
const context = coreMock.createPluginInitializerContext({});
const mockLogger = context.logger.get();
context.config.create = jest.fn().mockImplementation(() => {
return of({
search: {