From ce690eb9a5a973e96b879d03d8e3d1f627f7d4bf Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Tue, 5 Dec 2017 11:32:37 -0800 Subject: [PATCH 1/2] Add test coverage for EuiDescriptionList. --- .../description_list.test.js.snap | 75 +++++++++++++++++++ .../description_list/description_list.js | 4 + .../description_list/description_list.test.js | 73 +++++++++++++++++- 3 files changed, 150 insertions(+), 2 deletions(-) diff --git a/src/components/description_list/__snapshots__/description_list.test.js.snap b/src/components/description_list/__snapshots__/description_list.test.js.snap index e82fd9b344e..d894163cb8e 100644 --- a/src/components/description_list/__snapshots__/description_list.test.js.snap +++ b/src/components/description_list/__snapshots__/description_list.test.js.snap @@ -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 + +`; + +exports[`EuiDescriptionList props align center is rendered 1`] = ` +
+`; + +exports[`EuiDescriptionList props align left is rendered 1`] = ` +
+`; + +exports[`EuiDescriptionList props compressed is rendered 1`] = ` +
+`; + +exports[`EuiDescriptionList props listItems is rendered 1`] = ` +
+
+ Title 1 +
+
+ Description 1 +
+
+ Title 2 +
+
+ Description 2 +
+
+ Title 3 +
+
+ Description 3 +
+
+`; + +exports[`EuiDescriptionList props type column is rendered 1`] = ` +
+`; + +exports[`EuiDescriptionList props type inline is rendered 1`] = ` +
+`; + +exports[`EuiDescriptionList props type row is rendered 1`] = ` +
`; diff --git a/src/components/description_list/description_list.js b/src/components/description_list/description_list.js index 03f9b34eb07..1f47b6e61c6 100644 --- a/src/components/description_list/description_list.js +++ b/src/components/description_list/description_list.js @@ -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), diff --git a/src/components/description_list/description_list.test.js b/src/components/description_list/description_list.test.js index dd7732a82d4..257478dab0e 100644 --- a/src/components/description_list/description_list.test.js +++ b/src/components/description_list/description_list.test.js @@ -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( - + + Content + ); 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( + + listItems will render instead of this content + + ); + + expect(component) + .toMatchSnapshot(); + }); + }); + + describe('compressed', () => { + test('is rendered', () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + }); + + describe('type', () => { + TYPES.forEach(type => { + test(`${type} is rendered`, () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + }); + }); + + describe('align', () => { + ALIGNMENTS.forEach(alignment => { + test(`${alignment} is rendered`, () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + }); + }); + }); }); From 416a7971c57ff18b9fceea4bf3d72a71910fbe99 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Tue, 5 Dec 2017 11:33:33 -0800 Subject: [PATCH 2/2] Update test coverage for EuiDescriptionListTitle and EuiDescriptionListDescription. --- .../__snapshots__/description_list_description.test.js.snap | 4 +++- .../__snapshots__/description_list_title.test.js.snap | 4 +++- .../description_list/description_list_description.test.js | 4 +++- .../description_list/description_list_title.test.js | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/description_list/__snapshots__/description_list_description.test.js.snap b/src/components/description_list/__snapshots__/description_list_description.test.js.snap index b380d7f3a22..73afd8b550d 100644 --- a/src/components/description_list/__snapshots__/description_list_description.test.js.snap +++ b/src/components/description_list/__snapshots__/description_list_description.test.js.snap @@ -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 + `; diff --git a/src/components/description_list/__snapshots__/description_list_title.test.js.snap b/src/components/description_list/__snapshots__/description_list_title.test.js.snap index 05a256d203b..0b93e495fdf 100644 --- a/src/components/description_list/__snapshots__/description_list_title.test.js.snap +++ b/src/components/description_list/__snapshots__/description_list_title.test.js.snap @@ -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 + `; diff --git a/src/components/description_list/description_list_description.test.js b/src/components/description_list/description_list_description.test.js index 7c8510b2e58..7a5914390a6 100644 --- a/src/components/description_list/description_list_description.test.js +++ b/src/components/description_list/description_list_description.test.js @@ -7,7 +7,9 @@ import { EuiDescriptionListDescription } from './description_list_description'; describe('EuiDescriptionListDescription', () => { test('is rendered', () => { const component = render( - + + Content + ); expect(component) diff --git a/src/components/description_list/description_list_title.test.js b/src/components/description_list/description_list_title.test.js index 507bac14e8f..0f106f1dc16 100644 --- a/src/components/description_list/description_list_title.test.js +++ b/src/components/description_list/description_list_title.test.js @@ -7,7 +7,9 @@ import { EuiDescriptionListTitle } from './description_list_title'; describe('EuiDescriptionListTitle', () => { test('is rendered', () => { const component = render( - + + Content + ); expect(component)