Skip to content

Commit

Permalink
[ML] Fixing jest tests with unhandled promise rejections (#112804)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic authored Sep 22, 2021
1 parent 84e42e4 commit 1456257
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function prepareTest(messages) {
};
const kibana = {
services: {
notifications: { toasts: { addDanger: jest.fn() } },
notifications: { toasts: { addDanger: jest.fn(), addError: jest.fn() } },
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ function ExplorerChartContainer({
let isCancelled = false;
const generateLink = async () => {
if (!isCancelled && series.functionDescription !== ML_JOB_AGGREGATION.LAT_LONG) {
const singleMetricViewerLink = await getExploreSeriesLink(mlLocator, series, timefilter);
setExplorerSeriesLink(singleMetricViewerLink);
try {
const singleMetricViewerLink = await getExploreSeriesLink(mlLocator, series, timefilter);
setExplorerSeriesLink(singleMetricViewerLink);
} catch (error) {
setExplorerSeriesLink('');
}
}
};
generateLink();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { BucketSpanEstimatorData } from '../../../common/types/job_service';

import { estimateBucketSpanFactory } from './bucket_span_estimator';

jest.mock('../../lib/log', () => ({
mlLog: { warn: jest.fn() },
}));

const callAs = {
search: () => Promise.resolve({ body: {} }),
cluster: { getSettings: () => Promise.resolve({ body: {} }) },
Expand Down

0 comments on commit 1456257

Please sign in to comment.