Skip to content

Commit c990b34

Browse files
author
Alexander Fedyashov
committed
fix(shallow): fix shallow test util
1 parent 4d5e272 commit c990b34

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/utils/shallow.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ import { ShallowWrapper } from 'enzyme'
22

33
const meetsName = (wrapper, name) => name === wrapper.type().name
44

5-
const dive = wrapper => {
5+
const dive = (wrapper) => {
6+
/* eslint-disable no-param-reassign */
67
if (meetsName(wrapper, 'refHOC')) wrapper = wrapper.dive()
78
if (meetsName(wrapper, 'Ref')) wrapper = wrapper.dive()
9+
/* eslint-enable */
810

911
return wrapper
1012
}
1113

12-
class Wrapper extends ShallowWrapper {
13-
shallow(options) {
14-
return this.single('shallow', n => dive(new Wrapper(n, null, options)))
15-
}
14+
// Heads up! This monkey patch overrides behaviour of shallow() method of Enzyme
15+
const shallowMethod = ShallowWrapper.prototype.shallow
16+
17+
ShallowWrapper.prototype.shallow = function (...args) {
18+
return dive(shallowMethod.apply(this, ...args))
1619
}
1720

18-
export default (...args) => dive(new Wrapper(...args))
21+
export default (...args) => dive(new ShallowWrapper(...args))

0 commit comments

Comments
 (0)