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

[Emotion] Fix/regression test more css props #6248

Merged
merged 10 commits into from
Sep 20, 2022
Prev Previous commit
Next Next commit
Add more simple regression tests that don't require any src changes
  • Loading branch information
cee-chen committed Sep 20, 2022
commit e9773003f663e3e9d0ec0c17fdb7d139b55b9e34
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../../test/required_props';
import { shouldRenderCustomStyles } from '../../../test/internal';

import { EuiCollapsibleNavGroup, BACKGROUNDS } from './collapsible_nav_group';

describe('EuiCollapsibleNavGroup', () => {
shouldRenderCustomStyles(
<EuiCollapsibleNavGroup iconType="logoElastic" title="Test" />,
{ childProps: ['iconProps'] }
);

test('is rendered', () => {
const component = render(
<EuiCollapsibleNavGroup id="id" {...requiredProps} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { requiredProps } from '../../../test';
import { shouldRenderCustomStyles } from '../../../test/internal';

import { EuiFormRow } from '../form_row';
import { EuiDescribedFormGroup } from './described_form_group';
Expand All @@ -19,6 +20,10 @@ describe('EuiDescribedFormGroup', () => {
description: 'Test description',
};

shouldRenderCustomStyles(<EuiDescribedFormGroup {...props} />, {
childProps: ['descriptionFlexItemProps', 'fieldFlexItemProps'],
});

test('is rendered', () => {
const component = shallow(
<EuiDescribedFormGroup {...requiredProps} {...props}>
Expand Down
5 changes: 5 additions & 0 deletions src/components/form/field_password/field_password.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { render, mount } from 'enzyme';
import { requiredProps } from '../../../test/required_props';
import { shouldRenderCustomStyles } from '../../../test/internal';

import { EuiFieldPassword, EuiFieldPasswordProps } from './field_password';

Expand All @@ -23,6 +24,10 @@ const TYPES: Array<EuiFieldPasswordProps['type']> = [
];

describe('EuiFieldPassword', () => {
shouldRenderCustomStyles(<EuiFieldPassword type="dual" />, {
childProps: ['dualToggleProps'],
});

test('is rendered', () => {
const component = render(
<EuiFieldPassword
Expand Down
6 changes: 6 additions & 0 deletions src/components/form/radio/radio.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../../test';
import { shouldRenderCustomStyles } from '../../../test/internal';

import { EuiRadio } from './radio';

describe('EuiRadio', () => {
shouldRenderCustomStyles(
<EuiRadio onChange={() => {}} id="id" label="test" />,
{ childProps: ['labelProps'] }
);

test('is rendered', () => {
const component = render(
<EuiRadio id="id" onChange={() => {}} {...requiredProps} />
Expand Down
6 changes: 6 additions & 0 deletions src/components/form/super_select/super_select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { mount, render } from 'enzyme';
import { requiredProps, takeMountedSnapshot } from '../../../test';
import { shouldRenderCustomStyles } from '../../../test/internal';

import { EuiSuperSelect } from './super_select';

Expand All @@ -22,6 +23,11 @@ const options = [
];

describe('EuiSuperSelect', () => {
shouldRenderCustomStyles(
<EuiSuperSelect options={options} onChange={() => {}} />,
{ childProps: ['popoverProps'] }
);

test('is rendered', () => {
const component = render(
<EuiSuperSelect
Expand Down
12 changes: 12 additions & 0 deletions src/components/markdown_editor/markdown_editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@
import React from 'react';
import { render, mount, ReactWrapper } from 'enzyme';
import { requiredProps } from '../../test/required_props';
import { shouldRenderCustomStyles } from '../../test/internal';

import { EuiMarkdownEditor } from './markdown_editor';
import * as MarkdownTooltip from './plugins/markdown_tooltip';
import MarkdownActions from './markdown_actions';
import { getDefaultEuiMarkdownPlugins } from './plugins/markdown_default_plugins';

describe('EuiMarkdownEditor', () => {
shouldRenderCustomStyles(
<EuiMarkdownEditor
{...requiredProps}
onChange={() => {}}
value="Test"
initialViewMode="viewing"
/>,
{ childProps: ['markdownFormatProps'] }
);

test('is rendered', () => {
const component = render(
<EuiMarkdownEditor
Expand Down
13 changes: 13 additions & 0 deletions src/components/selectable/selectable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { mount, render } from 'enzyme';
import { requiredProps } from '../../test';
import { shouldRenderCustomStyles } from '../../test/internal';

import { EuiSelectable } from './selectable';
import { EuiSelectableOption } from './selectable_option';
Expand All @@ -28,6 +29,18 @@ const options: EuiSelectableOption[] = [
];

describe('EuiSelectable', () => {
shouldRenderCustomStyles(
<EuiSelectable options={options} searchable>
{(list, search) => (
<>
{search}
{list}
</>
)}
</EuiSelectable>,
{ childProps: ['searchProps', 'listProps'] }
);

test('is rendered', () => {
const component = render(
<EuiSelectable options={options} {...requiredProps} id="testId" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../../test/required_props';
import { shouldRenderCustomStyles } from '../../../test/internal';

import { EuiSelectableTemplateSitewide } from './selectable_template_sitewide';
import { EuiSelectableTemplateSitewideOption } from './selectable_template_sitewide_option';
Expand Down Expand Up @@ -74,6 +75,11 @@ const options: EuiSelectableTemplateSitewideOption[] = [
];

describe('EuiSelectableTemplateSitewide', () => {
shouldRenderCustomStyles(
<EuiSelectableTemplateSitewide options={options} />,
{ childProps: ['popoverProps'] }
);

test('is rendered', () => {
const component = render(
<EuiSelectableTemplateSitewide options={options} {...requiredProps} />
Expand Down
5 changes: 5 additions & 0 deletions src/components/side_nav/side_nav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';
import { shouldRenderCustomStyles } from '../../test/internal';

import { EuiSideNav } from './side_nav';
import { RenderItem } from './side_nav_item';

describe('EuiSideNav', () => {
shouldRenderCustomStyles(<EuiSideNav heading="Test" />, {
childProps: ['headingProps'],
});

test('is rendered', () => {
const component = render(<EuiSideNav {...requiredProps} />);

Expand Down