Skip to content

Commit

Permalink
fix(Search): strict validation to avoid errors when not using title (#…
Browse files Browse the repository at this point in the history
…2654)

* strict validation to avoid errors when using title

* updated tests
  • Loading branch information
Srinivas Devaki authored and levithomason committed Mar 27, 2018
1 parent 61c5146 commit 371c4e4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/modules/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class Search extends Component {
*/
results: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.shape(SearchResult.propTypes)),
PropTypes.object,
PropTypes.shape(SearchCategory.propTypes),
]),

/** Whether the search should automatically select the first result after searching. */
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Search/SearchResult.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface SearchResultProps {
renderer?: (props: SearchResultProps) => Array<React.ReactElement<any>>;

/** Display title. */
title?: string;
title: string;
}

declare const SearchResult: React.ComponentClass<SearchResultProps>;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Search/SearchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class SearchResult extends Component {
renderer: PropTypes.func,

/** Display title. */
title: PropTypes.string,
title: PropTypes.string.isRequired,
}

static defaultProps = {
Expand Down
4 changes: 3 additions & 1 deletion test/specs/modules/Search/SearchResult-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import SearchResult from 'src/modules/Search/SearchResult'
import * as common from 'test/specs/commonTests'

const requiredProps = { title: '' }

describe('SearchResult', () => {
common.isConformant(SearchResult)
common.isConformant(SearchResult, { requiredProps })
common.propKeyOnlyToClassName(SearchResult, 'active')
})

0 comments on commit 371c4e4

Please sign in to comment.