@@ -10,24 +10,25 @@ class TestClass {
1010}
1111
1212describe ( 'getUnhandledProps' , ( ) => {
13- it ( 'removes props defined in defaultProps' , ( ) => {
14- TestClass . defaultProps = { imHandled : 'thanks' } ;
15- new TestClass ( )
16- . unhandledProps
17- . should . not . have . any . keys ( _ . keys ( TestClass . defaultProps ) ) ;
18- } ) ;
1913 it ( 'removes props defined in propTypes' , ( ) => {
20- TestClass . propTypes = { imHandled : 'thanks' } ;
14+ TestClass . propTypes = { removeMe : 'thanks' } ;
2115 new TestClass ( )
2216 . unhandledProps
23- . should . not . have . any . keys ( _ . keys ( TestClass . defaultProps ) ) ;
17+ . should . not . have . any . keys ( _ . keys ( TestClass . propTypes ) ) ;
2418 } ) ;
25- it ( 'leave props not in defaultProps || propTypes in tact' , ( ) => {
26- TestClass . defaultProps = { imHandled : 'thanks' } ;
27- TestClass . propTypes = { alsoHandled : 'got it' } ;
28- const props = { thisShould : 'still be here' } ;
29- new TestClass ( props )
30- . unhandledProps
31- . should . eql ( props ) ;
19+ it ( 'leaves props if not defined in propTypes' , ( ) => {
20+ const userProps = { leaveThis : 'because it is unhandled' } ;
21+ TestClass . propTypes = { removeMe : 'because we are handling it' } ;
22+ const unhandled = new TestClass ( userProps ) . unhandledProps ;
23+
24+ unhandled . should . not . have . any . keys ( _ . keys ( TestClass . propTypes ) ) ;
25+ unhandled . should . have . all . keys ( _ . keys ( userProps ) ) ;
26+ } ) ;
27+ it ( 'leaves propType props if also defined in defaultProps' , ( ) => {
28+ TestClass . propTypes = { leaveMe : 'because it is also in defaultProps' } ;
29+ TestClass . defaultProps = { leaveMe : 'here i am' } ;
30+ const unhandled = new TestClass ( ) . unhandledProps ;
31+
32+ unhandled . should . have . all . keys ( _ . keys ( TestClass . defaultProps ) ) ;
3233 } ) ;
3334} ) ;
0 commit comments