Skip to content

Commit

Permalink
[Refactor] shallow/mount: Make all references to the wrapper `cla…
Browse files Browse the repository at this point in the history
…ss` call into `this.wrap`
  • Loading branch information
ljharb committed Jun 1, 2017
1 parent 2882aa8 commit 66f6662
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/ReactWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -924,11 +924,11 @@ class ReactWrapper {
* @param {ReactWrapper|ReactElement|Array<ReactElement>} node
* @returns {ReactWrapper}
*/
wrap(node) {
wrap(node, root = this.root, ...args) {
if (node instanceof ReactWrapper) {
return node;
}
return new ReactWrapper(node, this.root);
return new ReactWrapper(node, root, ...args);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ class ShallowWrapper {
* @returns {ShallowWrapper}
*/
shallow(options) {
return this.single('shallow', n => new ShallowWrapper(n, null, options));
return this.single('shallow', n => this.wrap(n, null, options));
}

/**
Expand Down Expand Up @@ -1039,11 +1039,11 @@ class ShallowWrapper {
* @param node
* @returns {ShallowWrapper}
*/
wrap(node) {
wrap(node, root = this.root, ...args) {
if (node instanceof ShallowWrapper) {
return node;
}
return new ShallowWrapper(node, this.root);
return new ShallowWrapper(node, root, ...args);
}

/**
Expand Down Expand Up @@ -1082,7 +1082,7 @@ class ShallowWrapper {
if (!isCustomComponentElement(n)) {
throw new TypeError(`ShallowWrapper::${name}() can only be called on components`);
}
return new ShallowWrapper(n, null, { ...this.options, ...options });
return this.wrap(n, null, { ...this.options, ...options });
});
}
}
Expand Down

0 comments on commit 66f6662

Please sign in to comment.