-
Notifications
You must be signed in to change notification settings - Fork 0
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
EuiSuggestItems tests pass #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiSuggestItem is rendered 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="euiSuggestItem testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
<span | ||
class="euiSuggestItem__type euiSuggestItem__type--primary" | ||
> | ||
<svg | ||
class="euiIcon euiIcon--medium euiIcon--primary euiIcon-isLoading" | ||
focusable="false" | ||
height="16" | ||
viewBox="0 0 16 16" | ||
width="16" | ||
xmlns="http://www.w3.org/2000/svg" | ||
/> | ||
</span> | ||
<span | ||
class="euiSuggestItem__label euiSuggestItem__layout--set" | ||
/> | ||
<span | ||
class="euiSuggestItem__description" | ||
/> | ||
</div> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our linter wants each selector on its own line |
||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
display: block; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for TypeScript things yet. I'll help you convert when the time comes. |
||
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Being more specific about what |
||
/** | ||
* Label for suggestion | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,14 @@ import { requiredProps } from '../../test/required_props'; | |
|
||
import { EuiSuggestItem } from './suggest_item'; | ||
|
||
const TYPE = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we made |
||
icon: 'search', | ||
color: 'primary', | ||
}; | ||
|
||
describe('EuiSuggestItem', () => { | ||
test('is rendered', () => { | ||
const component = render(<EuiSuggestItem {...requiredProps} />); | ||
const component = render(<EuiSuggestItem {...requiredProps} type={TYPE} />); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing text in the docs is weird sometimes. This just uses the unicode code for apostrophe so we don't have to escape it.