From e23f429523371077d53c932926cdc92b0cc05462 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Wed, 3 Jul 2019 12:31:11 -0500 Subject: [PATCH] tests passing --- .../suggest_item/suggest_item_example.js | 2 +- .../__snapshots__/suggest_item.test.js.snap | 28 +++++++++++++++++++ .../suggest_item/_suggest_item.scss | 5 ++-- src/components/suggest_item/suggest_item.js | 9 +++--- .../suggest_item/suggest_item.test.js | 7 ++++- 5 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 src/components/suggest_item/__snapshots__/suggest_item.test.js.snap diff --git a/src-docs/src/views/suggest_item/suggest_item_example.js b/src-docs/src/views/suggest_item/suggest_item_example.js index 1074acfa020..b3aa9e4b448 100644 --- a/src-docs/src/views/suggest_item/suggest_item_example.js +++ b/src-docs/src/views/suggest_item/suggest_item_example.js @@ -77,7 +77,7 @@ export const SuggestItemExample = { ], text: (

- By default EuiSuggestItem's{' '} + By default EuiSuggestItem's{' '} label will have a fixed width and use ellipsis whenever its content is too long. It is possible to show the full text by setting layout to inline. diff --git a/src/components/suggest_item/__snapshots__/suggest_item.test.js.snap b/src/components/suggest_item/__snapshots__/suggest_item.test.js.snap new file mode 100644 index 00000000000..5b1061eacd6 --- /dev/null +++ b/src/components/suggest_item/__snapshots__/suggest_item.test.js.snap @@ -0,0 +1,28 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EuiSuggestItem is rendered 1`] = ` +

+ + + + + +
+`; diff --git a/src/components/suggest_item/_suggest_item.scss b/src/components/suggest_item/_suggest_item.scss index d97fbea7bd8..7bee5338ff5 100644 --- a/src/components/suggest_item/_suggest_item.scss +++ b/src/components/suggest_item/_suggest_item.scss @@ -24,7 +24,7 @@ $buttonTypes: ( font-size: $euiFontSizeXS; // sass-lint:disable-block no-trailing-whitespace white-space: nowrap; - + @each $name, $color in $buttonTypes { .euiSuggestItem__type--#{$name} { background-color: tintOrShade($color, 90%, 50%); @@ -69,7 +69,8 @@ $buttonTypes: ( } } - .euiSuggestItem__description, .euiSuggestItem__label { + .euiSuggestItem__description, + .euiSuggestItem__label { overflow: hidden; text-overflow: ellipsis; display: block; diff --git a/src/components/suggest_item/suggest_item.js b/src/components/suggest_item/suggest_item.js index 9cfbd254a08..86d62876ca5 100644 --- a/src/components/suggest_item/suggest_item.js +++ b/src/components/suggest_item/suggest_item.js @@ -1,9 +1,7 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; -import { EuiIcon, IconPropType, IconColor, IconType } from '../icon'; -import { TypePredicateKind } from 'typescript'; +import { EuiIcon, IconPropType } from '../icon'; const colorToClassNameMap = { primary: 'euiSuggestItem__type--primary', @@ -65,7 +63,10 @@ EuiSuggestItem.propTypes = { /** * Takes 'icon' for EuiIcon and 'color'. 'color' can be either our palette colors (primary, secondary, etc) or a hex value. */ - type: PropTypes.object, + type: PropTypes.shape({ + icon: IconPropType, + color: PropTypes.oneOfType([PropTypes.oneOf(COLORS), PropTypes.string]), + }).isRequired, /** * Label for suggestion */ diff --git a/src/components/suggest_item/suggest_item.test.js b/src/components/suggest_item/suggest_item.test.js index 06bf12e108b..1c8c87c5fba 100644 --- a/src/components/suggest_item/suggest_item.test.js +++ b/src/components/suggest_item/suggest_item.test.js @@ -4,9 +4,14 @@ import { requiredProps } from '../../test/required_props'; import { EuiSuggestItem } from './suggest_item'; +const TYPE = { + icon: 'search', + color: 'primary', +}; + describe('EuiSuggestItem', () => { test('is rendered', () => { - const component = render(); + const component = render(); expect(component).toMatchSnapshot(); });