Skip to content

Commit

Permalink
fix jest tests and create mock
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Nov 4, 2020
1 parent ab40e09 commit 057fec9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { DataTierAllocationType } from '../../../public/application/sections/edi

import { Phases as PolicyPhases } from '../../../common/types';

import { KibanaContextProvider } from '../../../public/shared_imports';
import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock';

type Phases = keyof PolicyPhases;

import { POLICY_NAME } from './constants';
Expand Down Expand Up @@ -48,7 +51,17 @@ const testBedConfig: TestBedConfig = {
},
};

const initTestBed = registerTestBed<TestSubjects>(EditPolicy, testBedConfig);
const breadcrumbService = createBreadcrumbsMock();

const MyComponent = (props: any) => {
return (
<KibanaContextProvider services={{ breadcrumbService }}>
<EditPolicy {...props} />
</KibanaContextProvider>
);
};

const initTestBed = registerTestBed<TestSubjects>(MyComponent, testBedConfig);

type SetupReturn = ReturnType<typeof setup>;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { BreadcrumbService } from './breadcrumbs';

export const createBreadcrumbsMock = () => {
const breadcrumbService = new BreadcrumbService();
breadcrumbService.setup(jest.fn());
return breadcrumbService;
};

0 comments on commit 057fec9

Please sign in to comment.