From 6ef0c5c8a5d4e029dd1948ba0a0f48ebd24fc2c7 Mon Sep 17 00:00:00 2001 From: shahzad Date: Fri, 13 Mar 2020 21:36:24 +0100 Subject: [PATCH] update type --- .../uptime/public/state/api/__tests__/snapshot.test.ts | 8 ++++---- x-pack/legacy/plugins/uptime/public/state/api/utils.ts | 2 +- .../legacy/plugins/uptime/public/state/effects/monitor.ts | 8 ++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/x-pack/legacy/plugins/uptime/public/state/api/__tests__/snapshot.test.ts b/x-pack/legacy/plugins/uptime/public/state/api/__tests__/snapshot.test.ts index 2a7d50e942bca5..4788578b36b5c6 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/__tests__/snapshot.test.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/__tests__/snapshot.test.ts @@ -9,13 +9,13 @@ import { apiService } from '../utils'; import { HttpFetchError } from '../../../../../../../../src/core/public/http/http_fetch_error'; describe('snapshot API', () => { - let fetchMock: jest.SpyInstance>>; - let mockResponse: Partial; + let fetchMock: jest.SpyInstance>; + let mockResponse: Partial; beforeEach(() => { apiService.http = { get: jest.fn(), - }; + } as any; fetchMock = jest.spyOn(apiService.http, 'get'); mockResponse = { up: 3, down: 12, total: 15 }; }); @@ -63,7 +63,7 @@ describe('snapshot API', () => { }); it('throws an error when response is not ok', async () => { - mockResponse = new HttpFetchError('There was an error fetching your data.', 'error', {}); + mockResponse = new HttpFetchError('There was an error fetching your data.', 'error', {} as any); fetchMock.mockReturnValue(mockResponse); let error: Error | undefined; try { diff --git a/x-pack/legacy/plugins/uptime/public/state/api/utils.ts b/x-pack/legacy/plugins/uptime/public/state/api/utils.ts index fc0515df54404f..27b5ed34e7094c 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/utils.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/utils.ts @@ -28,7 +28,7 @@ class ApiService { return ApiService.instance; } - public async get(apiUrl: string, params: HttpFetchQuery) { + public async get(apiUrl: string, params?: HttpFetchQuery) { const response = await this._http!.get(apiUrl, { query: params }); if (response instanceof Error) { throw response; diff --git a/x-pack/legacy/plugins/uptime/public/state/effects/monitor.ts b/x-pack/legacy/plugins/uptime/public/state/effects/monitor.ts index 1cac7424b4e5ba..8f1e49a7878b51 100644 --- a/x-pack/legacy/plugins/uptime/public/state/effects/monitor.ts +++ b/x-pack/legacy/plugins/uptime/public/state/effects/monitor.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { call, put, takeLatest, select } from 'redux-saga/effects'; +import { call, put, takeLatest } from 'redux-saga/effects'; import { Action } from 'redux-actions'; import { FETCH_MONITOR_DETAILS, @@ -15,16 +15,13 @@ import { FETCH_MONITOR_LOCATIONS_FAIL, } from '../actions/monitor'; import { fetchMonitorDetails, fetchMonitorLocations } from '../api'; -import { getBasePath } from '../selectors'; import { MonitorDetailsActionPayload } from '../actions/types'; function* monitorDetailsEffect(action: Action) { const { monitorId, dateStart, dateEnd }: MonitorDetailsActionPayload = action.payload; try { - const basePath = yield select(getBasePath); const response = yield call(fetchMonitorDetails, { monitorId, - basePath, dateStart, dateEnd, }); @@ -37,8 +34,7 @@ function* monitorDetailsEffect(action: Action) { function* monitorLocationsEffect(action: Action) { const payload = action.payload; try { - const basePath = yield select(getBasePath); - const response = yield call(fetchMonitorLocations, { basePath, ...payload }); + const response = yield call(fetchMonitorLocations, payload); yield put({ type: FETCH_MONITOR_LOCATIONS_SUCCESS, payload: response }); } catch (error) { yield put({ type: FETCH_MONITOR_LOCATIONS_FAIL, payload: error.message });