Skip to content

Commit

Permalink
add test examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dominiqueclarke committed Jan 7, 2021
1 parent 69628a5 commit afea632
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 165 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,17 @@
*/

import React from 'react';
import { coreMock } from 'src/core/public/mocks';
import { renderWithRouter, shallowWithRouter } from '../../../lib';
import { renderTLWithRouter } from '../../../lib';
import { MLJobLink } from './ml_job_link';
import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public';

const core = coreMock.createStart();
describe('ML JobLink', () => {
it('shallow renders without errors', () => {
const wrapper = shallowWithRouter(
<MLJobLink dateRange={{ to: '', from: '' }} basePath="" monitorId="testMonitor" />
);
expect(wrapper).toMatchSnapshot();
});

it('renders without errors', () => {
const wrapper = renderWithRouter(
<KibanaContextProvider
services={{ ...core, triggersActionsUi: { getEditAlertFlyout: jest.fn() } }}
>
<MLJobLink dateRange={{ to: '', from: '' }} basePath="" monitorId="testMonitor" />
</KibanaContextProvider>
const { asFragment } = renderTLWithRouter(
<MLJobLink dateRange={{ to: '', from: '' }} basePath="" monitorId="testMonitor" />,
{
customCoreOptions: { triggersActionsUi: { getEditAlertFlyout: jest.fn() } },
}
);
expect(wrapper).toMatchSnapshot();
expect(asFragment()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import React from 'react';
import { ExecutedStep } from './executed_step';
import { Ping } from '../../../../common/runtime_types';
import { mountWithRouter } from '../../../lib';
import { mountWithRouter, renderTLWithRouter } from '../../../lib';

// FLAKY: https://github.com/elastic/kibana/issues/85899
describe.skip('ExecutedStep', () => {
describe('ExecutedStep', () => {
let step: Ping;

beforeEach(() => {
Expand All @@ -35,32 +35,11 @@ describe.skip('ExecutedStep', () => {
});

it('renders correct step heading', () => {
expect(
mountWithRouter(<ExecutedStep index={3} step={step} checkGroup={'fake-group'} />).find(
'EuiText'
)
).toMatchInlineSnapshot(`
<EuiText>
<div
className="euiText euiText--medium"
>
<strong>
<FormattedMessage
defaultMessage="{stepNumber}. {stepName}"
id="xpack.uptime.synthetics.executedStep.stepName"
values={
Object {
"stepName": "STEP_NAME",
"stepNumber": 4,
}
}
>
4. STEP_NAME
</FormattedMessage>
</strong>
</div>
</EuiText>
`);
const { getByText } = renderTLWithRouter(
<ExecutedStep index={3} step={step} checkGroup={'fake-group'} />
);

expect(getByText(`${step?.synthetics?.step?.index}. ${step?.synthetics?.step?.name}`));
});

it('renders a link to the step detail view', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ChromeBreadcrumb } from 'kibana/public';
import React from 'react';
import { Route } from 'react-router-dom';
import { of } from 'rxjs';
import { MountWithReduxProvider, mountWithRouter } from '../../../../lib';
import { MountWithReduxProvider, mountWithRouter, renderTLWithRouter } from '../../../../lib';
import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public';
import { useMonitorBreadcrumb } from './use_monitor_breadcrumb';
import { OVERVIEW_ROUTE } from '../../../../../common/constants';
Expand All @@ -27,14 +27,13 @@ describe('useMonitorBreadcrumbs', () => {
return <>Step Water Fall</>;
};

mountWithRouter(
renderTLWithRouter(
<MountWithReduxProvider>
<KibanaContextProvider services={{ ...core }}>
<Route path={OVERVIEW_ROUTE}>
<Component />
</Route>
</KibanaContextProvider>
</MountWithReduxProvider>
<Route path={OVERVIEW_ROUTE}>
<Component />
</Route>
</MountWithReduxProvider>,
{ kibanaProps: { services: { ...core } } }
);

expect(getBreadcrumbs()).toMatchInlineSnapshot(`
Expand Down

0 comments on commit afea632

Please sign in to comment.