Skip to content

Commit

Permalink
No portal
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonStoltz committed Nov 11, 2020
1 parent 1f3cd7d commit 99463bb
Showing 1 changed file with 0 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,13 @@ import '../../../../__mocks__/kea.mock';
import { setMockActions, setMockValues } from '../../../../__mocks__';

import React from 'react';
import ReactDOM from 'react-dom';
import { shallow } from 'enzyme';

import { LogRetentionConfirmationModal } from './log_retention_confirmation_modal';
import { ELogRetentionOptions } from './types';
import { GenericConfirmationModal } from './generic_confirmation_modal';

describe('<LogRetentionConfirmationModal />', () => {
beforeAll(() => {
// LogRetentionConfirmationModal contains EuiModals, which utilize React Portals,
// so we must mock `createPortal` to get the rendered element directly,
// instead of letting it be placed normally elsewhere in DOM (outside of jest's domain)
// @ts-ignore
ReactDOM.createPortal = jest.fn((element) => {
return element;
});
});

const actions = {
closeModals: jest.fn(),
saveLogRetention: jest.fn(),
Expand Down Expand Up @@ -57,12 +46,6 @@ describe('<LogRetentionConfirmationModal />', () => {
setMockValues(values);
});

afterEach(() => {
// Remove the jest mock on createPortal
// @ts-ignore
ReactDOM.createPortal.mockClear();
});

it('renders nothing by default', () => {
const logRetentionPanel = shallow(<LogRetentionConfirmationModal />);
expect(logRetentionPanel.isEmptyRender()).toBe(true);
Expand Down

0 comments on commit 99463bb

Please sign in to comment.