Skip to content

Commit

Permalink
[7.x] [AppServices] Fix unhandled promise rejections in search tests (#…
Browse files Browse the repository at this point in the history
…112849) (#113264)

* [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>
# Conflicts:
#	src/plugins/data/common/search/search_source/search_source.test.ts

* Fix lint issues
  • Loading branch information
jloleysens authored Sep 29, 2021
1 parent df7ed2f commit 09778a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { of } from 'rxjs';
import { of, throwError } from 'rxjs';
import { GetConfigFn } from '../../types';
import { IndexPattern } from '../..';
import { SearchSource, SearchSourceDependencies, SortDirection } from './';
Expand Down Expand Up @@ -1153,7 +1153,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);
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/data/server/search/search_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 09778a3

Please sign in to comment.