Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: lifecycleExperimental by default #1140

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
nodeEqual,
nodeMatches,
getAdapter,
makeOptions,
sym,
privateSet,
cloneElement,
Expand Down Expand Up @@ -66,12 +67,13 @@ function filterWhereUnwrapped(wrapper, predicate) {
* @class ReactWrapper
*/
class ReactWrapper {
constructor(nodes, root, options = {}) {
constructor(nodes, root, passedOptions = {}) {
if (!global.window && !global.document) {
throw new Error(
'It looks like you called `mount()` without a global document being loaded.',
);
}
const options = makeOptions(passedOptions);

if (!root) {
privateSet(this, UNRENDERED, nodes);
Expand Down
6 changes: 4 additions & 2 deletions packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
isCustomComponentElement,
ITERATOR_SYMBOL,
getAdapter,
makeOptions,
sym,
privateSet,
cloneElement,
Expand Down Expand Up @@ -108,8 +109,9 @@ function getRootNode(node) {
* @class ShallowWrapper
*/
class ShallowWrapper {
constructor(nodes, root, options = {}) {
validateOptions(options);
constructor(nodes, root, passedOptions = {}) {
validateOptions(passedOptions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come ReactWrapper doesn't validate its options?

const options = makeOptions(passedOptions);
if (!root) {
privateSet(this, ROOT, this);
privateSet(this, UNRENDERED, nodes);
Expand Down
7 changes: 7 additions & 0 deletions packages/enzyme/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export function getAdapter(options = {}) {
return adapter;
}

export function makeOptions(options) {
return {
...configuration.get(),
...options,
};
}

export function isCustomComponentElement(inst, adapter) {
return !!inst && adapter.isValidElement(inst) && typeof inst.type === 'function';
}
Expand Down