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 EuiBadge. #185

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
184 changes: 183 additions & 1 deletion src/components/badge/__snapshots__/badge.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,189 @@ exports[`EuiBadge is rendered 1`] = `
<span
class="euiBadge__content"
>
<span />
<span>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props color accent is rendered 1`] = `
<div
class="euiBadge euiBadge--accent"
>
<span
class="euiBadge__content"
>
<span>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props color danger is rendered 1`] = `
<div
class="euiBadge euiBadge--danger"
>
<span
class="euiBadge__content"
>
<span>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props color default is rendered 1`] = `
<div
class="euiBadge euiBadge--default"
>
<span
class="euiBadge__content"
>
<span>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props color primary is rendered 1`] = `
<div
class="euiBadge euiBadge--primary"
>
<span
class="euiBadge__content"
>
<span>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props color secondary is rendered 1`] = `
<div
class="euiBadge euiBadge--secondary"
>
<span
class="euiBadge__content"
>
<span>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props color warning is rendered 1`] = `
<div
class="euiBadge euiBadge--warning"
>
<span
class="euiBadge__content"
>
<span>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props iconSide left is rendered 1`] = `
<div
class="euiBadge euiBadge--default"
>
<span
class="euiBadge__content"
>
<svg
class="euiIcon euiBadge__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>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props iconSide right is rendered 1`] = `
<div
class="euiBadge euiBadge--default euiBadge--iconRight"
>
<span
class="euiBadge__content"
>
<svg
class="euiIcon euiBadge__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>
Content
</span>
</span>
</div>
`;

exports[`EuiBadge props iconType is rendered 1`] = `
<div
class="euiBadge euiBadge--default"
>
<span
class="euiBadge__content"
>
<svg
class="euiIcon euiBadge__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>
Content
</span>
</span>
</div>
`;
51 changes: 49 additions & 2 deletions src/components/badge/badge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,62 @@ import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiBadge } from './badge';
import { EuiBadge, COLORS, ICON_SIDES } from './badge';

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

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

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

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

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

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

describe('iconSide', () => {
ICON_SIDES.forEach(iconSide => {
it(`${iconSide} is rendered`, () => {
const component = render(
<EuiBadge iconType="user" iconSide={iconSide}>
Content
</EuiBadge>
);

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