File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,22 @@ Object {
2424}
2525`;
2626
27+ exports[`should not crash when using doctrine to parse a default prop that isn't in the props list 1`] = `
28+ Object {
29+ " description" : " The only true button.
30+ " ,
31+ " doclets" : Object {},
32+ " methods" : Array [],
33+ " props" : Object {
34+ " crash" : Object {
35+ " description" : " " ,
36+ " tags" : Object {},
37+ },
38+ },
39+ " tags" : Object {},
40+ }
41+ `;
42+
2743exports[`should remove non-public methods 1`] = `
2844Object {
2945 " doclets" : Object {},
Original file line number Diff line number Diff line change @@ -107,3 +107,17 @@ alert('Hello world');
107107
108108 expect ( result ) . toMatchSnapshot ( ) ;
109109} ) ;
110+
111+ it ( 'should not crash when using doctrine to parse a default prop that isn\'t in the props list' , ( ) => {
112+ const result = getProps ( {
113+ description : 'The only true button.' ,
114+ methods : [ ] ,
115+ props : {
116+ crash : {
117+ description : undefined ,
118+ } ,
119+ } ,
120+ } ) ;
121+
122+ expect ( result ) . toMatchSnapshot ( ) ;
123+ } ) ;
Original file line number Diff line number Diff line change @@ -68,7 +68,8 @@ module.exports = function getProps(doc) {
6868 Object . keys ( doc . props ) . forEach ( propName => {
6969 const prop = doc . props [ propName ] ;
7070 const doclets = getDocletsObject ( prop . description ) ;
71- const documentation = doctrine . parse ( prop . description ) ;
71+ // when a prop is listed in defaultProps but not in props the prop.description is undefined
72+ const documentation = doctrine . parse ( prop . description || '' ) ;
7273
7374 // documentation.description is the description without tags
7475 doc . props [ propName ] . description = documentation . description ;
You can’t perform that action at this time.
0 commit comments