From 41db653ce2caafb486261a559973cf3e4e0ec072 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 15 Jul 2020 16:27:56 +0100 Subject: [PATCH] initialising saved search in beforeEach --- .../jobs/new_job/utils/new_job_utils.test.ts | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.test.ts b/x-pack/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.test.ts index 6f765fac9bccd..f626018987526 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.test.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.test.ts @@ -10,48 +10,51 @@ import { SavedSearchSavedObject } from '../../../../../common/types/kibana'; import { createSearchItems } from './new_job_utils'; describe('createSearchItems', () => { - const savedSearch = ({ - client: { - http: { - basePath: { - basePath: '/abc', - serverBasePath: '/abc', - }, - anonymousPaths: {}, - }, - batchQueue: [], - }, - attributes: { - title: 'not test', - description: '', - hits: 0, - columns: ['_source'], - sort: [], - version: 1, - kibanaSavedObjectMeta: { - searchSourceJSON: '', - }, - }, - _version: 'WzI0OSw0XQ==', - id: '4b9b1010-c678-11ea-b6e6-e942978fa29c', - type: 'search', - migrationVersion: { - search: '7.4.0', - }, - references: [ - { - name: 'kibanaSavedObjectMeta.searchSourceJSON.index', - type: 'index-pattern', - id: '7e252840-bd27-11ea-8a6c-75d1a0bd08ab', - }, - ], - } as unknown) as SavedSearchSavedObject; - const kibanaConfig = {} as IUiSettingsClient; const indexPattern = ({ fields: [], } as unknown) as IIndexPattern; + let savedSearch = ({} as unknown) as SavedSearchSavedObject; + beforeEach(() => { + savedSearch = ({ + client: { + http: { + basePath: { + basePath: '/abc', + serverBasePath: '/abc', + }, + anonymousPaths: {}, + }, + batchQueue: [], + }, + attributes: { + title: 'not test', + description: '', + hits: 0, + columns: ['_source'], + sort: [], + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: '', + }, + }, + _version: 'WzI0OSw0XQ==', + id: '4b9b1010-c678-11ea-b6e6-e942978fa29c', + type: 'search', + migrationVersion: { + search: '7.4.0', + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: '7e252840-bd27-11ea-8a6c-75d1a0bd08ab', + }, + ], + } as unknown) as SavedSearchSavedObject; + }); + test('should match index pattern', () => { const resp = createSearchItems(kibanaConfig, indexPattern, null); expect(resp).toStrictEqual({