Skip to content

Commit

Permalink
Convert to ES modules
Browse files Browse the repository at this point in the history
  • Loading branch information
NMinhNguyen committed Feb 27, 2020
1 parent ba8ff6e commit d2d678e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 37 deletions.
8 changes: 1 addition & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@
* @flow
*/

'use strict';

const ReactShallowRenderer = require('./src/ReactShallowRenderer');

// TODO: decide on the top-level export form.
// This is hacky but makes it work with both Rollup and Jest.
module.exports = ReactShallowRenderer.default || ReactShallowRenderer;
export {default} from './src/ReactShallowRenderer';
16 changes: 5 additions & 11 deletions src/__tests__/ReactShallowRenderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@

'use strict';

let createRenderer;
let PropTypes;
let React;
import * as PropTypes from 'prop-types';
import * as React from 'react';
import ReactShallowRenderer from 'react-shallow-renderer';

describe('ReactShallowRenderer', () => {
beforeEach(() => {
jest.resetModules();

createRenderer = require('react-shallow-renderer').createRenderer;
PropTypes = require('prop-types');
React = require('react');
});
const createRenderer = ReactShallowRenderer.createRenderer;

describe('ReactShallowRenderer', () => {
it('should call all of the legacy lifecycle hooks', () => {
const logs = [];
const logger = message => () => logs.push(message) || true;
Expand Down
12 changes: 4 additions & 8 deletions src/__tests__/ReactShallowRendererHooks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@

'use strict';

let createRenderer;
let React;
import * as React from 'react';
import ReactShallowRenderer from 'react-shallow-renderer';

describe('ReactShallowRenderer with hooks', () => {
beforeEach(() => {
jest.resetModules();
createRenderer = require('react-shallow-renderer').createRenderer;
React = require('react');
});
const createRenderer = ReactShallowRenderer.createRenderer;

describe('ReactShallowRenderer with hooks', () => {
it('should work with useState', () => {
function SomeComponent({defaultName}) {
const [name] = React.useState(defaultName);
Expand Down
16 changes: 5 additions & 11 deletions src/__tests__/ReactShallowRendererMemo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@

'use strict';

let createRenderer;
let PropTypes;
let React;
import * as PropTypes from 'prop-types';
import * as React from 'react';
import ReactShallowRenderer from 'react-shallow-renderer';

describe('ReactShallowRendererMemo', () => {
beforeEach(() => {
jest.resetModules();

createRenderer = require('react-shallow-renderer').createRenderer;
PropTypes = require('prop-types');
React = require('react');
});
const createRenderer = ReactShallowRenderer.createRenderer;

describe('ReactShallowRendererMemo', () => {
it('should call all of the legacy lifecycle hooks', () => {
const logs = [];
const logger = message => () => logs.push(message) || true;
Expand Down

0 comments on commit d2d678e

Please sign in to comment.