Skip to content

Commit 1f184f1

Browse files
committed
Fix Jest tests.
1 parent b57b80e commit 1f184f1

File tree

4 files changed

+108
-69
lines changed

4 files changed

+108
-69
lines changed

x-pack/plugins/index_lifecycle_management/__jest__/__snapshots__/policy_table.test.tsx.snap

Lines changed: 72 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import React from 'react';
99
import { act } from 'react-dom/test-utils';
1010
import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest';
11+
import { KibanaPageTemplate } from '../../../../../../src/plugins/kibana_react/public';
1112
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public/context';
1213
import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock';
1314
import { licensingMock } from '../../../../licensing/public/mocks';
@@ -17,7 +18,13 @@ const breadcrumbService = createBreadcrumbsMock();
1718

1819
const AppWithContext = (props: any) => {
1920
return (
20-
<KibanaContextProvider services={{ breadcrumbService, license: licensingMock.createLicense() }}>
21+
<KibanaContextProvider
22+
services={{
23+
breadcrumbService,
24+
license: licensingMock.createLicense(),
25+
managementPageLayout: KibanaPageTemplate,
26+
}}
27+
>
2128
<App {...props} />
2229
</KibanaContextProvider>
2330
);

x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/init_test_bed.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { registerTestBed, TestBedConfig } from '@kbn/test/jest';
1010

1111
import '../helpers/global_mocks';
1212

13+
import { KibanaPageTemplate } from '../../../../../../src/plugins/kibana_react/public';
1314
import { licensingMock } from '../../../../licensing/public/mocks';
1415
import { EditPolicy } from '../../../public/application/sections/edit_policy';
1516
import { KibanaContextProvider } from '../../../public/shared_imports';
@@ -38,6 +39,7 @@ const EditPolicyContainer = ({ appServicesContext, ...rest }: any) => {
3839
services={{
3940
breadcrumbService,
4041
license: licensingMock.createLicense({ license: { type: 'enterprise' } }),
42+
managementPageLayout: KibanaPageTemplate,
4143
...appServicesContext,
4244
}}
4345
>

x-pack/plugins/index_lifecycle_management/__jest__/policy_table.test.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
} from '../../../../src/core/public/mocks';
1919
import { HttpService } from '../../../../src/core/public/http';
2020
import { usageCollectionPluginMock } from '../../../../src/plugins/usage_collection/public/mocks';
21+
import { KibanaPageTemplate } from '../../../../src/plugins/kibana_react/public';
22+
import { KibanaContextProvider } from '../public/shared_imports';
2123

2224
import { PolicyFromES } from '../common/types';
2325
import { PolicyTable } from '../public/application/sections/policy_table/policy_table';
@@ -84,23 +86,35 @@ const openContextMenu = (buttonIndex: number) => {
8486
describe('policy table', () => {
8587
beforeEach(() => {
8688
component = (
87-
<PolicyTable
88-
policies={policies}
89-
history={scopedHistoryMock.create()}
90-
navigateToApp={jest.fn()}
91-
updatePolicies={jest.fn()}
92-
/>
89+
<KibanaContextProvider
90+
services={{
91+
managementPageLayout: KibanaPageTemplate,
92+
}}
93+
>
94+
<PolicyTable
95+
policies={policies}
96+
history={scopedHistoryMock.create()}
97+
navigateToApp={jest.fn()}
98+
updatePolicies={jest.fn()}
99+
/>
100+
</KibanaContextProvider>
93101
);
94102
});
95103

96104
test('should show empty state when there are not any policies', () => {
97105
component = (
98-
<PolicyTable
99-
policies={[]}
100-
history={scopedHistoryMock.create()}
101-
navigateToApp={jest.fn()}
102-
updatePolicies={jest.fn()}
103-
/>
106+
<KibanaContextProvider
107+
services={{
108+
managementPageLayout: KibanaPageTemplate,
109+
}}
110+
>
111+
<PolicyTable
112+
policies={[]}
113+
history={scopedHistoryMock.create()}
114+
navigateToApp={jest.fn()}
115+
updatePolicies={jest.fn()}
116+
/>
117+
</KibanaContextProvider>
104118
);
105119
const rendered = mountWithIntl(component);
106120
mountedSnapshot(rendered);

0 commit comments

Comments
 (0)