From dc6509784d7ec172f618ec1301eeecdb4e36a2a0 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Mon, 4 Dec 2017 17:30:21 -0800 Subject: [PATCH] Add test coverage for EuiAvatar. (#184) --- .../avatar/__snapshots__/avatar.test.js.snap | 94 +++++++++++++++++++ src/components/avatar/avatar.js | 2 +- src/components/avatar/avatar.test.js | 51 ++++++++++ 3 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 src/components/avatar/__snapshots__/avatar.test.js.snap create mode 100644 src/components/avatar/avatar.test.js diff --git a/src/components/avatar/__snapshots__/avatar.test.js.snap b/src/components/avatar/__snapshots__/avatar.test.js.snap new file mode 100644 index 00000000000..b5c82dd3cdd --- /dev/null +++ b/src/components/avatar/__snapshots__/avatar.test.js.snap @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EuiAvatar is rendered 1`] = ` +
+ +
+`; + +exports[`EuiAvatar props imageUrl is rendered 1`] = ` +
+`; + +exports[`EuiAvatar props size l is rendered 1`] = ` +
+ +
+`; + +exports[`EuiAvatar props size m is rendered 1`] = ` +
+ +
+`; + +exports[`EuiAvatar props size none is rendered 1`] = ` +
+ +
+`; + +exports[`EuiAvatar props size s is rendered 1`] = ` +
+ +
+`; + +exports[`EuiAvatar props size xl is rendered 1`] = ` +
+ +
+`; diff --git a/src/components/avatar/avatar.js b/src/components/avatar/avatar.js index 160b2b1093e..1c9a0eff913 100644 --- a/src/components/avatar/avatar.js +++ b/src/components/avatar/avatar.js @@ -53,10 +53,10 @@ export const EuiAvatar = ({ }; EuiAvatar.propTypes = { - children: PropTypes.node, className: PropTypes.string, imageUrl: PropTypes.string, name: PropTypes.string.isRequired, + size: PropTypes.oneOf(SIZES), }; EuiAvatar.defaultProps = { diff --git a/src/components/avatar/avatar.test.js b/src/components/avatar/avatar.test.js new file mode 100644 index 00000000000..76eafea5ca4 --- /dev/null +++ b/src/components/avatar/avatar.test.js @@ -0,0 +1,51 @@ +import React from 'react'; +import { render } from 'enzyme'; +import { requiredProps } from '../../test/required_props'; + +import { EuiAvatar, SIZES } from './avatar'; + +describe('EuiAvatar', () => { + test('is rendered', () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + + describe('props', () => { + describe('imageUrl', () => { + it('is rendered', () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + }); + + describe('size', () => { + SIZES.forEach(size => { + it(`${size} is rendered`, () => { + const component = render( + + ); + + expect(component) + .toMatchSnapshot(); + }); + }); + }); + }); +});