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 EuiDescriptionList #189

Merged
merged 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,80 @@ exports[`EuiDescriptionList is rendered 1`] = `
aria-label="aria-label"
class="euiDescriptionList euiDescriptionList--row testClass1 testClass2"
data-test-subj="test subject string"
>
Content
</dl>
`;

exports[`EuiDescriptionList props align center is rendered 1`] = `
<dl
class="euiDescriptionList euiDescriptionList--row euiDescriptionList--center"
/>
`;

exports[`EuiDescriptionList props align left is rendered 1`] = `
<dl
class="euiDescriptionList euiDescriptionList--row"
/>
`;

exports[`EuiDescriptionList props compressed is rendered 1`] = `
<dl
class="euiDescriptionList euiDescriptionList--row euiDescriptionList--compressed"
/>
`;

exports[`EuiDescriptionList props listItems is rendered 1`] = `
<dl
class="euiDescriptionList euiDescriptionList--row"
>
<dt
class="euiDescriptionList__title"
>
Title 1
</dt>
<dd
class="euiDescriptionList__description"
>
Description 1
</dd>
<dt
class="euiDescriptionList__title"
>
Title 2
</dt>
<dd
class="euiDescriptionList__description"
>
Description 2
</dd>
<dt
class="euiDescriptionList__title"
>
Title 3
</dt>
<dd
class="euiDescriptionList__description"
>
Description 3
</dd>
</dl>
`;

exports[`EuiDescriptionList props type column is rendered 1`] = `
<dl
class="euiDescriptionList euiDescriptionList--column"
/>
`;

exports[`EuiDescriptionList props type inline is rendered 1`] = `
<dl
class="euiDescriptionList euiDescriptionList--inline"
/>
`;

exports[`EuiDescriptionList props type row is rendered 1`] = `
<dl
class="euiDescriptionList euiDescriptionList--row"
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ exports[`EuiDescriptionListDescription is rendered 1`] = `
aria-label="aria-label"
class="euiDescriptionList__description testClass1 testClass2"
data-test-subj="test subject string"
/>
>
Content
</dd>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ exports[`EuiDescriptionListTitle is rendered 1`] = `
aria-label="aria-label"
class="euiDescriptionList__title testClass1 testClass2"
data-test-subj="test subject string"
/>
>
Content
</dt>
`;
4 changes: 4 additions & 0 deletions src/components/description_list/description_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export const EuiDescriptionList = ({
EuiDescriptionList.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
listItems: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string,
description: PropTypes.string,
})),
compressed: PropTypes.bool,
type: PropTypes.oneOf(TYPES),
align: PropTypes.oneOf(ALIGNMENTS),
Expand Down
73 changes: 71 additions & 2 deletions src/components/description_list/description_list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,84 @@ import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiDescriptionList } from './description_list';
import { EuiDescriptionList, TYPES, ALIGNMENTS } from './description_list';

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

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

describe('props', () => {
describe('listItems', () => {
test('is rendered', () => {
const listItems = [
{
title: 'Title 1',
description: 'Description 1',
},
{
title: 'Title 2',
description: 'Description 2',
},
{
title: 'Title 3',
description: 'Description 3',
},
];

const component = render(
<EuiDescriptionList listItems={listItems}>
listItems will render instead of this content
</EuiDescriptionList>
);

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

describe('compressed', () => {
test('is rendered', () => {
const component = render(
<EuiDescriptionList compressed />
);

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

describe('type', () => {
TYPES.forEach(type => {
test(`${type} is rendered`, () => {
const component = render(
<EuiDescriptionList type={type} />
);

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

describe('align', () => {
ALIGNMENTS.forEach(alignment => {
test(`${alignment} is rendered`, () => {
const component = render(
<EuiDescriptionList align={alignment} />
);

expect(component)
.toMatchSnapshot();
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { EuiDescriptionListDescription } from './description_list_description';
describe('EuiDescriptionListDescription', () => {
test('is rendered', () => {
const component = render(
<EuiDescriptionListDescription {...requiredProps} />
<EuiDescriptionListDescription {...requiredProps}>
Content
</EuiDescriptionListDescription>
);

expect(component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { EuiDescriptionListTitle } from './description_list_title';
describe('EuiDescriptionListTitle', () => {
test('is rendered', () => {
const component = render(
<EuiDescriptionListTitle {...requiredProps} />
<EuiDescriptionListTitle {...requiredProps}>
Content
</EuiDescriptionListTitle>
);

expect(component)
Expand Down