@@ -58,6 +58,12 @@ export default (Component, options = {}) => {
58
58
: options . ShorthandComponent
59
59
60
60
describe ( `${ propKey } shorthand prop (common)` , ( ) => {
61
+ let wrapper
62
+
63
+ afterEach ( ( ) => {
64
+ if ( wrapper && wrapper . unmount ) wrapper . unmount ( )
65
+ } )
66
+
61
67
assertRequired ( Component , 'a `Component`' )
62
68
assertRequired ( _ . isPlainObject ( options ) , 'an `options` object' )
63
69
assertRequired ( propKey , 'a `propKey`' )
@@ -70,7 +76,7 @@ export default (Component, options = {}) => {
70
76
overrideProps : shorthandOverrideProps ,
71
77
autoGenerateKey,
72
78
} )
73
- const wrapper = mount ( React . createElement ( Component , { ...requiredProps , [ propKey ] : value } ) )
79
+ wrapper = mount ( React . createElement ( Component , { ...requiredProps , [ propKey ] : value } ) )
74
80
75
81
const result = wrapper . find ( ShorthandComponent )
76
82
@@ -86,7 +92,7 @@ export default (Component, options = {}) => {
86
92
87
93
if ( alwaysPresent || ( Component . defaultProps && Component . defaultProps [ propKey ] ) ) {
88
94
it ( `has default ${ name } when not defined` , ( ) => {
89
- const wrapper = mount ( React . createElement ( Component , requiredProps ) )
95
+ wrapper = mount ( React . createElement ( Component , requiredProps ) )
90
96
91
97
wrapper . should . have . descendants ( ShorthandComponent )
92
98
} )
@@ -96,7 +102,7 @@ export default (Component, options = {}) => {
96
102
}
97
103
98
104
it ( `has no ${ name } when not defined` , ( ) => {
99
- const wrapper = mount ( React . createElement ( Component , requiredProps ) )
105
+ wrapper = mount ( React . createElement ( Component , requiredProps ) )
100
106
101
107
wrapper . should . not . have . descendants ( ShorthandComponent )
102
108
} )
@@ -105,7 +111,7 @@ export default (Component, options = {}) => {
105
111
if ( ! alwaysPresent ) {
106
112
it ( `has no ${ name } when null` , ( ) => {
107
113
const element = React . createElement ( Component , { ...requiredProps , [ propKey ] : null } )
108
- const wrapper = mount ( element )
114
+ wrapper = mount ( element )
109
115
110
116
wrapper . should . not . have . descendants ( ShorthandComponent )
111
117
} )
0 commit comments