@@ -534,6 +534,76 @@ describe('generateProps (correct)', () => {
534534 } )
535535 } )
536536 } )
537+
538+ describe ( 'given a required exact' , ( ) => {
539+ describe ( 'with a required array value' , ( ) => {
540+ it ( 'generates an object with an array value' , ( ) => {
541+ if ( ! PropTypes . exact ) return
542+
543+ const propTypes = { myExact : PropTypes . exact ( { myArray : PropTypes . array . isRequired } ) . isRequired }
544+ ComponentAsClass . propTypes = propTypes
545+ ComponentAsFunction . propTypes = propTypes
546+
547+ const expected = { myExact : { myArray : [ 'myArray' ] } }
548+
549+ generateProps ( propTypes ) . should . deep . equal ( expected )
550+ generateProps ( { propTypes } ) . should . deep . equal ( expected )
551+ generateProps ( ComponentAsClass ) . should . deep . equal ( expected )
552+ generateProps ( ComponentAsFunction ) . should . deep . equal ( expected )
553+ generateProps ( propTypes . myExact ) . should . deep . equal ( expected . myExact )
554+ } )
555+
556+ describe ( 'and a required bool' , ( ) => {
557+ it ( 'generates an object with an array value and a bool value' , ( ) => {
558+ if ( ! PropTypes . exact ) return
559+
560+ const propTypes = {
561+ myExact : PropTypes . exact ( {
562+ myArray : PropTypes . array . isRequired ,
563+ myBool : PropTypes . bool . isRequired
564+ } ) . isRequired
565+ }
566+ ComponentAsClass . propTypes = propTypes
567+ ComponentAsFunction . propTypes = propTypes
568+
569+ const expected = { myExact : { myArray : [ 'myArray' ] , myBool : true } }
570+
571+ generateProps ( propTypes ) . should . deep . equal ( expected )
572+ generateProps ( { propTypes } ) . should . deep . equal ( expected )
573+ generateProps ( ComponentAsClass ) . should . deep . equal ( expected )
574+ generateProps ( ComponentAsFunction ) . should . deep . equal ( expected )
575+ generateProps ( propTypes . myExact ) . should . deep . equal ( expected . myExact )
576+ } )
577+ } )
578+
579+ describe ( 'and a required shape' , ( ) => {
580+ describe ( 'with a required number' , ( ) => {
581+ it ( 'generates an object with an array value and a sub-object with bool value' , ( ) => {
582+ if ( ! PropTypes . exact ) return
583+
584+ const propTypes = {
585+ myExact : PropTypes . exact ( {
586+ myArray : PropTypes . array . isRequired ,
587+ mySubShape : PropTypes . shape ( {
588+ myNumber : PropTypes . number . isRequired
589+ } ) . isRequired
590+ } ) . isRequired
591+ }
592+ ComponentAsClass . propTypes = propTypes
593+ ComponentAsFunction . propTypes = propTypes
594+
595+ const expected = { myExact : { myArray : [ 'myArray' ] , mySubShape : { myNumber : 1 } } }
596+
597+ generateProps ( propTypes ) . should . deep . equal ( expected )
598+ generateProps ( { propTypes } ) . should . deep . equal ( expected )
599+ generateProps ( ComponentAsClass ) . should . deep . equal ( expected )
600+ generateProps ( ComponentAsFunction ) . should . deep . equal ( expected )
601+ generateProps ( propTypes . myExact ) . should . deep . equal ( expected . myExact )
602+ } )
603+ } )
604+ } )
605+ } )
606+ } )
537607} )
538608
539609describe ( 'generateProps(opts)' , ( ) => {
0 commit comments