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 all 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
4 changes: 2 additions & 2 deletions src/modules/Search/Search.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export interface SearchProps {
minCharacters?: number;

/** Additional text for "No Results" message with less emphasis. */
noResultsDescription?: string;
noResultsDescription?: React.ReactNode;

/** 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
4 changes: 2 additions & 2 deletions src/modules/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export default class Search extends Component {
minCharacters: PropTypes.number,

/** Additional text for "No Results" message with less emphasis. */
noResultsDescription: PropTypes.string,
noResultsDescription: PropTypes.node,

/** 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