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 9fa4bb2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 40 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: 4 additions & 12 deletions src/__tests__/ReactShallowRenderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,13 @@
* @jest-environment node
*/

'use strict';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import ReactShallowRenderer from 'react-shallow-renderer';

let createRenderer;
let PropTypes;
let React;
const createRenderer = ReactShallowRenderer.createRenderer;

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

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

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

'use strict';
import * as React from 'react';
import ReactShallowRenderer from 'react-shallow-renderer';

let createRenderer;
let React;
const createRenderer = ReactShallowRenderer.createRenderer;

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

it('should work with useState', () => {
function SomeComponent({defaultName}) {
const [name] = React.useState(defaultName);
Expand Down
16 changes: 4 additions & 12 deletions src/__tests__/ReactShallowRendererMemo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,13 @@
* @jest-environment node
*/

'use strict';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import ReactShallowRenderer from 'react-shallow-renderer';

let createRenderer;
let PropTypes;
let React;
const createRenderer = ReactShallowRenderer.createRenderer;

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

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

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

0 comments on commit 9fa4bb2

Please sign in to comment.