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 EuiButton, EuiButtonIcon, and EuiButtonEmpty #187

Merged
merged 3 commits 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
220 changes: 220 additions & 0 deletions src/components/button/__snapshots__/button.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,226 @@ exports[`EuiButton is rendered 1`] = `
class="euiButton euiButton--primary testClass1 testClass2"
data-test-subj="test subject string"
type="button"
>
<span
class="euiButton__content"
>
<span>
Content
</span>
</span>
</button>
`;

exports[`EuiButton props color danger is rendered 1`] = `
<button
class="euiButton euiButton--danger"
type="button"
>
<span
class="euiButton__content"
>
<span />
</span>
</button>
`;

exports[`EuiButton props color ghost is rendered 1`] = `
<button
class="euiButton euiButton--ghost"
type="button"
>
<span
class="euiButton__content"
>
<span />
</span>
</button>
`;

exports[`EuiButton props color primary is rendered 1`] = `
<button
class="euiButton euiButton--primary"
type="button"
>
<span
class="euiButton__content"
>
<span />
</span>
</button>
`;

exports[`EuiButton props color secondary is rendered 1`] = `
<button
class="euiButton euiButton--secondary"
type="button"
>
<span
class="euiButton__content"
>
<span />
</span>
</button>
`;

exports[`EuiButton props color warning is rendered 1`] = `
<button
class="euiButton euiButton--warning"
type="button"
>
<span
class="euiButton__content"
>
<span />
</span>
</button>
`;

exports[`EuiButton props fill is rendered 1`] = `
<button
class="euiButton euiButton--primary euiButton--fill"
type="button"
>
<span
class="euiButton__content"
>
<span />
</span>
</button>
`;

exports[`EuiButton props iconSide left is rendered 1`] = `
<button
class="euiButton euiButton--primary"
type="button"
>
<span
class="euiButton__content"
>
<svg
aria-hidden="true"
class="euiIcon euiButton__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>
</button>
`;

exports[`EuiButton props iconSide right is rendered 1`] = `
<button
class="euiButton euiButton--primary euiButton--iconRight"
type="button"
>
<span
class="euiButton__content"
>
<svg
aria-hidden="true"
class="euiIcon euiButton__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>
</button>
`;

exports[`EuiButton props iconType is rendered 1`] = `
<button
class="euiButton euiButton--primary"
type="button"
>
<span
class="euiButton__content"
>
<svg
aria-hidden="true"
class="euiIcon euiButton__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>
</button>
`;

exports[`EuiButton props isDisabled is rendered 1`] = `
<button
class="euiButton euiButton--primary"
disabled=""
type="button"
>
<span
class="euiButton__content"
>
<span />
</span>
</button>
`;

exports[`EuiButton props size l is rendered 1`] = `
<button
class="euiButton euiButton--primary euiButton--large"
type="button"
>
<span
class="euiButton__content"
>
<span />
</span>
</button>
`;

exports[`EuiButton props size s is rendered 1`] = `
<button
class="euiButton euiButton--primary euiButton--small"
type="button"
>
<span
class="euiButton__content"
Expand Down
87 changes: 85 additions & 2 deletions src/components/button/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,98 @@ import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiButton } from './button';
import {
EuiButton,
COLORS,
SIZES,
ICON_SIDES,
} from './button';

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

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

describe('props', () => {
describe('fill', () => {
it('is rendered', () => {
const component = render(
<EuiButton fill />
);

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

describe('isDisabled', () => {
it('is rendered', () => {
const component = render(
<EuiButton isDisabled />
);

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

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

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

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

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

describe('size', () => {
SIZES.forEach(size => {
test(`${size} is rendered`, () => {
const component = render(
<EuiButton size={size} />
);

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

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

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