Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Wrap FunComponent in unit test with IntlProvider #654

Merged
merged 1 commit into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/public/application/ui/app_container.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
import { mount } from 'enzyme';
import { mountWithIntl } from 'test_utils/enzyme_helpers';

import { AppContainer } from './app_container';
import { Mounter, AppMountParameters, AppStatus } from '../types';
Expand Down Expand Up @@ -82,7 +83,7 @@ describe('AppContainer', () => {
const [waitPromise, resolvePromise] = createResolver();
const mounter = createMounter(waitPromise);

const wrapper = mount(
const wrapper = mountWithIntl(
<AppContainer
appPath={`/app/${appId}`}
appId={appId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
*/

import React from 'react';
import { mount } from 'enzyme';
import { ServerStatus } from './server_status';
import { FormattedStatus } from '../lib';
import { mountWithIntl } from 'test_utils/enzyme_helpers';

const getStatus = (parts: Partial<FormattedStatus['state']> = {}): FormattedStatus['state'] => ({
id: 'green',
Expand All @@ -46,7 +46,7 @@ const getStatus = (parts: Partial<FormattedStatus['state']> = {}): FormattedStat
describe('ServerStatus', () => {
it('renders correctly for green state', () => {
const status = getStatus();
const component = mount(<ServerStatus serverState={status} name="My Computer" />);
const component = mountWithIntl(<ServerStatus serverState={status} name="My Computer" />);
expect(component.find('EuiTitle').text()).toMatchInlineSnapshot(
`"OpenSearch Dashboards status is Green"`
);
Expand All @@ -58,18 +58,20 @@ describe('ServerStatus', () => {
id: 'red',
title: 'Red',
});
const component = mount(<ServerStatus serverState={status} name="My Computer" />);
const component = mountWithIntl(<ServerStatus serverState={status} name="My Computer" />);
expect(component.find('EuiTitle').text()).toMatchInlineSnapshot(
`"OpenSearch Dashboards status is Red"`
);
expect(component.find('EuiBadge')).toMatchSnapshot();
});

it('displays the correct `name`', () => {
let component = mount(<ServerStatus serverState={getStatus()} name="Localhost" />);
let component = mountWithIntl(<ServerStatus serverState={getStatus()} name="Localhost" />);
expect(component.find('EuiText').text()).toMatchInlineSnapshot(`"Localhost"`);

component = mount(<ServerStatus serverState={getStatus()} name="OpenSearchDashboards" />);
component = mountWithIntl(
<ServerStatus serverState={getStatus()} name="OpenSearchDashboards" />
);
expect(component.find('EuiText').text()).toMatchInlineSnapshot(`"OpenSearchDashboards"`);
});
});
Loading