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

Convert to ES modules #14

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
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