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

feat(Search): noResultsMessage prop can be a node #1683

Merged
merged 3 commits into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/modules/Search/Search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface SearchProps {
noResultsDescription?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@b0gok Thanks for a PR. I think that we need make same changes for noResultsDescription.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@layershifter Should I add specific test for case when noResultsDescription isn't a string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be awesome.


/** Message to display when there are no results. */
noResultsMessage?: string;
noResultsMessage?: React.ReactNode;

/** Controls whether or not the results menu is displayed. */
open?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class Search extends Component {
noResultsDescription: PropTypes.string,

/** Message to display when there are no results. */
noResultsMessage: PropTypes.string,
noResultsMessage: PropTypes.node,

/** Controls whether or not the results menu is displayed. */
open: PropTypes.bool,
Expand Down
9 changes: 8 additions & 1 deletion test/specs/modules/Search/Search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,20 @@ describe('Search', () => {
.find('.message.empty .header')
.should.have.text('No results found.')
})
it('uses custom noResultsMessage', () => {
it('uses custom string for noResultsMessage', () => {
wrapperMount(<Search results={[]} minCharacters={0} noResultsMessage='Something custom' />)

wrapper
.find('.message.empty .header')
.should.have.text('Something custom')
})
it('uses custom component for noResultsMessage', () => {
wrapperMount(<Search results={[]} minCharacters={0} noResultsMessage={<span>Test</span>} />)

wrapper
.find('.message.empty .header')
.should.contain.descendants('span')
})
it('uses custom noResultsDescription if present', () => {
wrapperMount(<Search results={[]} minCharacters={0} noResultsDescription='Something custom' />)

Expand Down