Skip to content

Commit

Permalink
Add test coverage for EuiBadge.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Dec 5, 2017
1 parent dc65097 commit 4759e32
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 1 deletion.
126 changes: 126 additions & 0 deletions src/components/badge/__snapshots__/badge.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,129 @@ exports[`EuiBadge is rendered 1`] = `
</span>
</div>
`;

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

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

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

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

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

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

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

exports[`EuiBadge props iconSide right is rendered 1`] = `
<div
class="euiBadge euiBadge--default euiBadge--iconRight"
>
<span
class="euiBadge__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 />
</span>
</div>
`;
41 changes: 40 additions & 1 deletion src/components/badge/badge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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', () => {
Expand All @@ -13,4 +13,43 @@ describe('EuiBadge', () => {
expect(component)
.toMatchSnapshot();
});

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

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

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

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

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

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

0 comments on commit 4759e32

Please sign in to comment.