Skip to content

Commit

Permalink
[Refactor] Utils: configuration: change to named exports.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 7, 2018
1 parent 84a7ad8 commit d7f3261
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/enzyme-test-suite/test/Adapter-spec.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import { expect } from 'chai';
import jsdom from 'jsdom';
import configuration from 'enzyme/build/configuration';
import { get } from 'enzyme/build/configuration';
import { configure, shallow } from 'enzyme';

import './_helpers/setupAdapters';
Expand All @@ -10,7 +10,7 @@ import { renderToString } from './_helpers/react-compat';
import { REACT013, REACT16 } from './_helpers/version';
import { itIf, describeWithDOM } from './_helpers';

const { adapter } = configuration.get();
const { adapter } = get();

const prettyFormat = o => JSON.stringify(o, null, 2);

Expand Down
4 changes: 2 additions & 2 deletions packages/enzyme-test-suite/test/Debug-spec.jsx
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import React from 'react';
import { mount, shallow } from 'enzyme';
import configuration from 'enzyme/build/configuration';
import { get } from 'enzyme/build/configuration';
import {
spaces,
indent,
Expand All @@ -17,7 +17,7 @@ import {
} from './_helpers';
import { REACT013 } from './_helpers/version';

const { adapter } = configuration.get();
const { adapter } = get();

const debugElement = element => debugNode(adapter.elementToNode(element));

Expand Down
6 changes: 3 additions & 3 deletions packages/enzyme/src/Utils.js
Expand Up @@ -6,7 +6,7 @@ import functionName from 'function.prototype.name';
import has from 'has';
import flat from 'array.prototype.flat';

import configuration from './configuration';
import { get } from './configuration';
import validateAdapter from './validateAdapter';
import { childrenOfNode } from './RSTTraversal';

Expand All @@ -17,7 +17,7 @@ export function getAdapter(options = {}) {
validateAdapter(options.adapter);
return options.adapter;
}
const { adapter } = configuration.get();
const { adapter } = get();
validateAdapter(adapter);
return adapter;
}
Expand All @@ -39,7 +39,7 @@ export function makeOptions(options) {
};

return {
...configuration.get(),
...get(),
...options,
...mountTargets,
};
Expand Down
19 changes: 10 additions & 9 deletions packages/enzyme/src/configuration.js
Expand Up @@ -2,12 +2,13 @@ import validateAdapter from './validateAdapter';

const configuration = {};

module.exports = {
get() { return { ...configuration }; },
merge(extra) {
if (extra.adapter) {
validateAdapter(extra.adapter);
}
Object.assign(configuration, extra);
},
};
export function get() {
return { ...configuration };
}

export function merge(extra) {
if (extra.adapter) {
validateAdapter(extra.adapter);
}
Object.assign(configuration, extra);
}

0 comments on commit d7f3261

Please sign in to comment.