mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Test callout behavior with different API responses
This commit is contained in:
parent
5d095d1896
commit
1db3d4e859
1 changed files with 32 additions and 3 deletions
|
@ -7,11 +7,19 @@
|
|||
|
||||
import { mount } from 'enzyme';
|
||||
import React from 'react';
|
||||
import { MlJobCompatibilityCallout } from './index';
|
||||
|
||||
import { TestProviders } from '../../../../common/mock';
|
||||
import { useInstalledSecurityJobs } from '../../../../common/components/ml/hooks/use_installed_security_jobs';
|
||||
import { MlJobCompatibilityCallout } from './index';
|
||||
|
||||
jest.mock('../../../../common/components/ml/hooks/use_installed_security_jobs');
|
||||
|
||||
describe('MlJobCompatibilityCallout', () => {
|
||||
it('renders when v2 jobs are installed', () => {
|
||||
it('renders when new affected jobs are installed', () => {
|
||||
(useInstalledSecurityJobs as jest.Mock).mockReturnValue({
|
||||
loading: false,
|
||||
jobs: [{ id: 'v2_linux_rare_metadata_process' }],
|
||||
});
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<MlJobCompatibilityCallout />
|
||||
|
@ -20,7 +28,24 @@ describe('MlJobCompatibilityCallout', () => {
|
|||
expect(wrapper.exists('[data-test-subj="callout-ml-job-compatibility"]')).toEqual(true);
|
||||
});
|
||||
|
||||
it('does not render if no v2 jobs are installed', () => {
|
||||
it('renders when old affected jobs are installed', () => {
|
||||
(useInstalledSecurityJobs as jest.Mock).mockReturnValue({
|
||||
loading: false,
|
||||
jobs: [{ id: 'linux_rare_metadata_process' }],
|
||||
});
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<MlJobCompatibilityCallout />
|
||||
</TestProviders>
|
||||
);
|
||||
expect(wrapper.exists('[data-test-subj="callout-ml-job-compatibility"]')).toEqual(true);
|
||||
});
|
||||
|
||||
it('does not render if no affected jobs are installed', () => {
|
||||
(useInstalledSecurityJobs as jest.Mock).mockReturnValue({
|
||||
loading: false,
|
||||
jobs: [{ id: 'windows_rare_user_type10_remote_login' }],
|
||||
});
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<MlJobCompatibilityCallout />
|
||||
|
@ -30,6 +55,10 @@ describe('MlJobCompatibilityCallout', () => {
|
|||
});
|
||||
|
||||
it('does not render while jobs are loading', () => {
|
||||
(useInstalledSecurityJobs as jest.Mock).mockReturnValue({
|
||||
loading: true,
|
||||
jobs: [],
|
||||
});
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<MlJobCompatibilityCallout />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue