Skip to content

Commit 550818a

Browse files
committed
fix tests with unmount
1 parent 5563ada commit 550818a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/specs/commonTests/implementsShorthandProp.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ export default (Component, options = {}) => {
5858
: options.ShorthandComponent
5959

6060
describe(`${propKey} shorthand prop (common)`, () => {
61+
let wrapper
62+
63+
afterEach(() => {
64+
if (wrapper && wrapper.unmount) wrapper.unmount()
65+
})
66+
6167
assertRequired(Component, 'a `Component`')
6268
assertRequired(_.isPlainObject(options), 'an `options` object')
6369
assertRequired(propKey, 'a `propKey`')
@@ -70,7 +76,7 @@ export default (Component, options = {}) => {
7076
overrideProps: shorthandOverrideProps,
7177
autoGenerateKey,
7278
})
73-
const wrapper = mount(React.createElement(Component, { ...requiredProps, [propKey]: value }))
79+
wrapper = mount(React.createElement(Component, { ...requiredProps, [propKey]: value }))
7480

7581
const result = wrapper.find(ShorthandComponent)
7682

@@ -86,7 +92,7 @@ export default (Component, options = {}) => {
8692

8793
if (alwaysPresent || (Component.defaultProps && Component.defaultProps[propKey])) {
8894
it(`has default ${name} when not defined`, () => {
89-
const wrapper = mount(React.createElement(Component, requiredProps))
95+
wrapper = mount(React.createElement(Component, requiredProps))
9096

9197
wrapper.should.have.descendants(ShorthandComponent)
9298
})
@@ -96,7 +102,7 @@ export default (Component, options = {}) => {
96102
}
97103

98104
it(`has no ${name} when not defined`, () => {
99-
const wrapper = mount(React.createElement(Component, requiredProps))
105+
wrapper = mount(React.createElement(Component, requiredProps))
100106

101107
wrapper.should.not.have.descendants(ShorthandComponent)
102108
})
@@ -105,7 +111,7 @@ export default (Component, options = {}) => {
105111
if (!alwaysPresent) {
106112
it(`has no ${name} when null`, () => {
107113
const element = React.createElement(Component, { ...requiredProps, [propKey]: null })
108-
const wrapper = mount(element)
114+
wrapper = mount(element)
109115

110116
wrapper.should.not.have.descendants(ShorthandComponent)
111117
})

0 commit comments

Comments
 (0)