Skip to content

Commit

Permalink
[Discover] skip any type for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaanj committed May 5, 2021
1 parent cbff694 commit 902473a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function createIndexPatternsStub() {
* A stubbed search source with a `fetch` method that returns all of `_stubHits`.
*/
export function createSearchSourceStub(hits: EsHitRecordList, timeField?: string) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const searchSourceStub: any = {
_stubHits: hits,
_stubTimeField: timeField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('context app', function () {
anchorId: string,
sort: EsQuerySortValue[]
) => Promise<AnchorHitRecord>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let searchSourceStub: any;

describe('function fetchAnchor', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EsHitRecordList, fetchContextProvider } from './context';
import { setServices, SortDirection } from '../../../../kibana_services';
import { AnchorHitRecord } from './anchor';
import { Query } from '../../../../../../data/public';
import { DiscoverServices } from '../../../../build_services';

const MS_PER_DAY = 24 * 60 * 60 * 1000;
const ANCHOR_TIMESTAMP = new Date(MS_PER_DAY).toJSON();
Expand All @@ -37,21 +38,22 @@ describe('context app', function () {
tieBreakerValue: number,
size: number
) => Promise<EsHitRecordList>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockSearchSource: any;

describe('function fetchPredecessors', function () {
beforeEach(() => {
mockSearchSource = createContextSearchSourceStub('@timestamp');

setServices({
setServices(({
data: {
search: {
searchSource: {
create: jest.fn().mockImplementation(() => mockSearchSource),
},
},
},
});
} as unknown) as DiscoverServices);

fetchPredecessors = (
indexPatternId,
Expand Down Expand Up @@ -235,15 +237,15 @@ describe('context app', function () {
beforeEach(() => {
mockSearchSource = createContextSearchSourceStub('@timestamp');

setServices({
setServices(({
data: {
search: {
searchSource: {
create: jest.fn().mockImplementation(() => mockSearchSource),
},
},
},
});
} as unknown) as DiscoverServices);

fetchPredecessors = (
indexPatternId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { setServices, SortDirection } from '../../../../kibana_services';
import { Query } from '../../../../../../data/public';
import { EsHitRecordList, fetchContextProvider } from './context';
import { AnchorHitRecord } from './anchor';
import { DiscoverServices } from '../../../../build_services';

const MS_PER_DAY = 24 * 60 * 60 * 1000;
const ANCHOR_TIMESTAMP = new Date(MS_PER_DAY).toJSON();
Expand All @@ -37,21 +38,22 @@ describe('context app', function () {
tieBreakerValue: number,
size: number
) => Promise<EsHitRecordList>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockSearchSource: any;

describe('function fetchSuccessors', function () {
beforeEach(() => {
mockSearchSource = createContextSearchSourceStub('@timestamp');

setServices({
setServices(({
data: {
search: {
searchSource: {
create: jest.fn().mockImplementation(() => mockSearchSource),
},
},
},
});
} as unknown) as DiscoverServices);

fetchSuccessors = (
indexPatternId,
Expand Down Expand Up @@ -238,15 +240,15 @@ describe('context app', function () {
beforeEach(() => {
mockSearchSource = createContextSearchSourceStub('@timestamp');

setServices({
setServices(({
data: {
search: {
searchSource: {
create: jest.fn().mockImplementation(() => mockSearchSource),
},
},
},
});
} as unknown) as DiscoverServices);

fetchSuccessors = (
indexPatternId,
Expand Down

0 comments on commit 902473a

Please sign in to comment.