From d764194a32c5ac22a0b3b1b6470bb0bd6767f8e2 Mon Sep 17 00:00:00 2001 From: Tzvi Melamed Date: Tue, 7 Aug 2018 08:41:47 -0400 Subject: [PATCH] Change sandbox naming to be more generic --- docs/installation/mount-tracking.md | 4 ++-- .../enzyme-test-suite/test/ReactWrapper-spec.jsx | 10 +++++----- .../test/ShallowWrapper-spec.jsx | 10 +++++----- .../test/mountTracking-spec.jsx | 12 ++++++------ packages/enzyme/src/index.js | 4 ++-- packages/enzyme/src/mount.js | 4 ++-- packages/enzyme/src/shallow.js | 4 ++-- .../src/{mountTracking.js => wrapperSandbox.js} | 16 ++++++++-------- 8 files changed, 32 insertions(+), 32 deletions(-) rename packages/enzyme/src/{mountTracking.js => wrapperSandbox.js} (67%) diff --git a/docs/installation/mount-tracking.md b/docs/installation/mount-tracking.md index 486afda6f..09f0856d6 100644 --- a/docs/installation/mount-tracking.md +++ b/docs/installation/mount-tracking.md @@ -12,7 +12,7 @@ import Adapter from 'enzyme-adapter-react-16'; configure({ adapter: new Adapter(), - enableMountTracking: true, + enableSandbox: true, }); ``` @@ -39,7 +39,7 @@ var Adapter = require('enzyme-adapter-react-16'); enzyme.configure({ adapter: new Adapter(), - enableMountTracking: true, + enableSandbox: true, }); ``` diff --git a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx index 01e7740b1..f6fa04c87 100644 --- a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx +++ b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx @@ -15,7 +15,7 @@ import { sym, } from 'enzyme/build/Utils'; import getAdapter from 'enzyme/build/getAdapter'; -import * as mountTracking from 'enzyme/build/mountTracking'; +import * as wrapperSandbox from 'enzyme/build/wrapperSandbox'; import './_helpers/setupAdapters'; import { @@ -81,13 +81,13 @@ describeWithDOM('mount', () => { expect(spy).to.have.property('callCount', 1); }); - it('should call trackMountedWrapper', () => { + it('should call trackWrapper', () => { const spy = sinon.spy(); - const originalTrackMountedWrapper = mountTracking.trackMountedWrapper; - mountTracking.trackMountedWrapper = spy; + const originalTrackWrapper = wrapperSandbox.trackWrapper; + wrapperSandbox.trackWrapper = spy; mount(

foo

); expect(spy).to.have.property('callCount', 1); - mountTracking.trackMountedWrapper = originalTrackMountedWrapper; + wrapperSandbox.trackWrapper = originalTrackWrapper; }); }); diff --git a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx index 4d37803df..f27ebe2d2 100644 --- a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx +++ b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx @@ -15,7 +15,7 @@ import { sym, } from 'enzyme/build/Utils'; import getAdapter from 'enzyme/build/getAdapter'; -import * as mountTracking from 'enzyme/build/mountTracking'; +import * as wrapperSandbox from 'enzyme/build/wrapperSandbox'; import './_helpers/setupAdapters'; import { @@ -77,13 +77,13 @@ describe('shallow', () => { expect(wrapper.children().props().bam).to.equal(undefined); }); - it('should call trackMountedWrapper', () => { + it('should call trackWrapper', () => { const spy = sinon.spy(); - const originalTrackMountedWrapper = mountTracking.trackMountedWrapper; - mountTracking.trackMountedWrapper = spy; + const originalTrackWrapper = wrapperSandbox.trackWrapper; + wrapperSandbox.trackWrapper = spy; shallow(

foo

); expect(spy).to.have.property('callCount', 1); - mountTracking.trackMountedWrapper = originalTrackMountedWrapper; + wrapperSandbox.trackWrapper = originalTrackWrapper; }); }); diff --git a/packages/enzyme-test-suite/test/mountTracking-spec.jsx b/packages/enzyme-test-suite/test/mountTracking-spec.jsx index a0ad3869c..d9d9d5e2b 100644 --- a/packages/enzyme-test-suite/test/mountTracking-spec.jsx +++ b/packages/enzyme-test-suite/test/mountTracking-spec.jsx @@ -5,13 +5,13 @@ import { ReactWrapper, configure } from 'enzyme'; import { get } from 'enzyme/build/configuration'; import { - trackMountedWrapper, + trackWrapper, unmountAllWrappers, -} from 'enzyme/build/mountTracking'; +} from 'enzyme/build/wrapperSandbox'; const originalConfig = get(); -describe('mountTracking', () => { +describe('wrapperSandbox', () => { afterEach(() => { configure(originalConfig); }); @@ -21,13 +21,13 @@ describe('mountTracking', () => { const spy = sinon.spy(); wrapper.unmount = spy; - trackMountedWrapper(wrapper); + trackWrapper(wrapper); unmountAllWrappers(); // default configuration is not to track wrappers expect(spy).to.have.property('callCount', 0); - configure({ enableMountTracking: true }); - trackMountedWrapper(wrapper); + configure({ enableSandbox: true }); + trackWrapper(wrapper); unmountAllWrappers(); // default configuration is not to track wrappers expect(spy).to.have.property('callCount', 1); diff --git a/packages/enzyme/src/index.js b/packages/enzyme/src/index.js index 09fd209b5..8369855ae 100644 --- a/packages/enzyme/src/index.js +++ b/packages/enzyme/src/index.js @@ -6,7 +6,7 @@ import mount from './mount'; import shallow from './shallow'; import render from './render'; import { merge as configure } from './configuration'; -import { trackMountedWrapper, unmountAllWrappers } from './mountTracking'; +import { trackWrapper, unmountAllWrappers } from './wrapperSandbox'; module.exports = { render, @@ -16,6 +16,6 @@ module.exports = { ReactWrapper, configure, EnzymeAdapter, - trackMountedWrapper, + trackWrapper, unmountAllWrappers, }; diff --git a/packages/enzyme/src/mount.js b/packages/enzyme/src/mount.js index e36a1cab5..ee9dd9b76 100644 --- a/packages/enzyme/src/mount.js +++ b/packages/enzyme/src/mount.js @@ -1,5 +1,5 @@ import ReactWrapper from './ReactWrapper'; -import { trackMountedWrapper } from './mountTracking'; +import { trackWrapper } from './wrapperSandbox'; /** * Mounts and renders a react component into the document and provides a testing wrapper around it. @@ -9,6 +9,6 @@ import { trackMountedWrapper } from './mountTracking'; */ export default function mount(node, options) { const wrapper = new ReactWrapper(node, null, options); - trackMountedWrapper(wrapper); + trackWrapper(wrapper); return wrapper; } diff --git a/packages/enzyme/src/shallow.js b/packages/enzyme/src/shallow.js index 1aa082382..24c5003a1 100644 --- a/packages/enzyme/src/shallow.js +++ b/packages/enzyme/src/shallow.js @@ -1,5 +1,5 @@ import ShallowWrapper from './ShallowWrapper'; -import { trackMountedWrapper } from './mountTracking'; +import { trackWrapper } from './wrapperSandbox'; /** * Shallow renders a react component and provides a testing wrapper around it. @@ -9,6 +9,6 @@ import { trackMountedWrapper } from './mountTracking'; */ export default function shallow(node, options) { const wrapper = new ShallowWrapper(node, null, options); - trackMountedWrapper(wrapper); + trackWrapper(wrapper); return wrapper; } diff --git a/packages/enzyme/src/mountTracking.js b/packages/enzyme/src/wrapperSandbox.js similarity index 67% rename from packages/enzyme/src/mountTracking.js rename to packages/enzyme/src/wrapperSandbox.js index 6e098ff94..8f1f27435 100644 --- a/packages/enzyme/src/mountTracking.js +++ b/packages/enzyme/src/wrapperSandbox.js @@ -1,6 +1,6 @@ import { get } from './configuration'; -const mountedWrappers = new Set(); +const wrappers = new Set(); /** * Stores a reference to a testing wrapper for later unmounting @@ -8,15 +8,15 @@ const mountedWrappers = new Set(); * * @param {ReactWrapper|ShallowWrapper} wrapper */ -export function trackMountedWrapper(wrapper) { - const { enableMountTracking } = get(); - if (enableMountTracking) { - mountedWrappers.add(wrapper); +export function trackWrapper(wrapper) { + const { enableSandbox } = get(); + if (enableSandbox) { + wrappers.add(wrapper); } } /** - * Unmounts all actively mounted Enzyme wrappers. + * Unmounts all sandboxed Enzyme wrappers. * * Usually, this can be run once for an entire test suite after all each test * (and its nested hooks)have been run. However, in some cases this may need @@ -26,6 +26,6 @@ export function trackMountedWrapper(wrapper) { * identifiers being invalid. */ export function unmountAllWrappers() { - mountedWrappers.forEach(wrapper => wrapper.unmount()); - mountedWrappers.clear(); + wrappers.forEach(wrapper => wrapper.unmount()); + wrappers.clear(); }