Skip to content

Commit 371c4e4

Browse files
Srinivas Devakilevithomason
authored andcommitted
fix(Search): strict validation to avoid errors when not using title (Semantic-Org#2654)
* strict validation to avoid errors when using title * updated tests
1 parent 61c5146 commit 371c4e4

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/modules/Search/Search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default class Search extends Component {
7171
*/
7272
results: PropTypes.oneOfType([
7373
PropTypes.arrayOf(PropTypes.shape(SearchResult.propTypes)),
74-
PropTypes.object,
74+
PropTypes.shape(SearchCategory.propTypes),
7575
]),
7676

7777
/** Whether the search should automatically select the first result after searching. */

src/modules/Search/SearchResult.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface SearchResultProps {
4545
renderer?: (props: SearchResultProps) => Array<React.ReactElement<any>>;
4646

4747
/** Display title. */
48-
title?: string;
48+
title: string;
4949
}
5050

5151
declare const SearchResult: React.ComponentClass<SearchResultProps>;

src/modules/Search/SearchResult.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default class SearchResult extends Component {
7373
renderer: PropTypes.func,
7474

7575
/** Display title. */
76-
title: PropTypes.string,
76+
title: PropTypes.string.isRequired,
7777
}
7878

7979
static defaultProps = {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import SearchResult from 'src/modules/Search/SearchResult'
22
import * as common from 'test/specs/commonTests'
33

4+
const requiredProps = { title: '' }
5+
46
describe('SearchResult', () => {
5-
common.isConformant(SearchResult)
7+
common.isConformant(SearchResult, { requiredProps })
68
common.propKeyOnlyToClassName(SearchResult, 'active')
79
})

0 commit comments

Comments
 (0)