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

Add test coverage for EuiCallOut. #188

Merged
merged 1 commit into from
Dec 5, 2017
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
115 changes: 115 additions & 0 deletions src/components/call_out/__snapshots__/call_out.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,120 @@ exports[`EuiCallOut is rendered 1`] = `
class="euiCallOutHeader__title"
/>
</div>
<div
class="euiText euiText--small"
>
Content
</div>
</div>
`;

exports[`EuiCallOut props color danger is rendered 1`] = `
<div
class="euiCallOut euiCallOut--danger"
>
<div
class="euiCallOutHeader"
>
<span
class="euiCallOutHeader__title"
/>
</div>
</div>
`;

exports[`EuiCallOut props color primary is rendered 1`] = `
<div
class="euiCallOut euiCallOut--primary"
>
<div
class="euiCallOutHeader"
>
<span
class="euiCallOutHeader__title"
/>
</div>
</div>
`;

exports[`EuiCallOut props color success is rendered 1`] = `
<div
class="euiCallOut euiCallOut--success"
>
<div
class="euiCallOutHeader"
>
<span
class="euiCallOutHeader__title"
/>
</div>
</div>
`;

exports[`EuiCallOut props color warning is rendered 1`] = `
<div
class="euiCallOut euiCallOut--warning"
>
<div
class="euiCallOutHeader"
>
<span
class="euiCallOutHeader__title"
/>
</div>
</div>
`;

exports[`EuiCallOut props iconType is rendered 1`] = `
<div
class="euiCallOut euiCallOut--primary"
>
<div
class="euiCallOutHeader"
>
<svg
aria-hidden="true"
class="euiIcon euiCallOutHeader__icon euiIcon--medium"
height="18"
viewBox="0 0 18 18"
width="18"
xmlns="http://www.w3.org/2000/svg"
>
<g
fill-rule="evenodd"
>
<path
d="M13.689 11.132c1.155 1.222 1.953 2.879 2.183 4.748a1.007 1.007 0 0 1-1 1.12H3.007a1.005 1.005 0 0 1-1-1.12c.23-1.87 1.028-3.526 2.183-4.748.247.228.505.442.782.633-1.038 1.069-1.765 2.55-1.972 4.237L14.872 16c-.204-1.686-.93-3.166-1.966-4.235a7.01 7.01 0 0 0 .783-.633zM8.939 1c1.9 0 3 2 4.38 2.633a2.483 2.483 0 0 1-1.88.867c-.298 0-.579-.06-.844-.157A3.726 3.726 0 0 1 7.69 5.75c-1.395 0-3.75.25-3.245-1.903C5.94 3 6.952 1 8.94 1z"
/>
<path
d="M8.94 2c2.205 0 4 1.794 4 4s-1.795 4-4 4c-2.207 0-4-1.794-4-4s1.793-4 4-4m0 9A5 5 0 1 0 8.937.999 5 5 0 0 0 8.94 11"
/>
</g>
</svg>
<span
class="euiCallOutHeader__title"
/>
</div>
</div>
`;

exports[`EuiCallOut props title is rendered 1`] = `
<div
class="euiCallOut euiCallOut--primary"
>
<div
class="euiCallOutHeader"
>
<span
class="euiCallOutHeader__title"
>
Title
</span>
</div>
<div
class="euiText euiText--small"
>
Content
</div>
</div>
`;
11 changes: 10 additions & 1 deletion src/components/call_out/call_out.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ const colorToClassNameMap = {

export const COLORS = Object.keys(colorToClassNameMap);

export const EuiCallOut = ({ title, color, iconType, children, className, ...rest }) => {
export const EuiCallOut = ({
title,
color,
iconType,
children,
className,
...rest
}) => {
const classes = classNames('euiCallOut', colorToClassNameMap[color], className);

let headerIcon;
Expand Down Expand Up @@ -65,6 +72,8 @@ export const EuiCallOut = ({ title, color, iconType, children, className, ...res
};

EuiCallOut.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
title: PropTypes.node,
iconType: PropTypes.oneOf(ICON_TYPES),
color: PropTypes.oneOf(COLORS),
Expand Down
45 changes: 43 additions & 2 deletions src/components/call_out/call_out.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,56 @@ import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiCallOut } from './call_out';
import { EuiCallOut, COLORS } from './call_out';

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

expect(component)
.toMatchSnapshot();
});

describe('props', () => {
describe('title', () => {
it('is rendered', () => {
const component = render(
<EuiCallOut title="Title">
Content
</EuiCallOut>
);

expect(component)
.toMatchSnapshot();
});
});

describe('iconType', () => {
it('is rendered', () => {
const component = render(
<EuiCallOut iconType="user" />
);

expect(component)
.toMatchSnapshot();
});
});

describe('color', () => {
COLORS.forEach(color => {
test(`${color} is rendered`, () => {
const component = render(
<EuiCallOut color={color} />
);

expect(component)
.toMatchSnapshot();
});
});
});
});
});