Fix tests errors and warnings - iteration 3 (#12212) (#12219)

This commit is contained in:
Michael S. Molina
2021-01-26 04:40:59 -03:00
committed by GitHub
parent 22d52eadb2
commit 6bf5d2c06d
6 changed files with 62 additions and 5 deletions

View File

@@ -21,11 +21,12 @@ import React from 'react';
import { styledMount as mount } from 'spec/helpers/theming';
import sinon from 'sinon';
import ReactMarkdown from 'react-markdown';
import { act } from 'react-dom/test-utils';
import { MarkdownEditor } from 'src/components/AsyncAceEditor';
import Markdown from 'src/dashboard/components/gridComponents/Markdown';
import MarkdownModeDropdown from 'src/dashboard/components/menu/MarkdownModeDropdown';
import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
import DragDroppable from 'src/dashboard/components/dnd/DragDroppable';
import WithPopoverMenu from 'src/dashboard/components/menu/WithPopoverMenu';
import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer';
@@ -45,6 +46,8 @@ describe('Markdown', () => {
editMode: false,
availableColumnCount: 12,
columnWidth: 50,
redoLength: 0,
undoLength: 0,
onResizeStart() {},
onResize() {},
onResizeStop() {},
@@ -52,6 +55,7 @@ describe('Markdown', () => {
updateComponents() {},
deleteComponent() {},
logEvent() {},
addDangerToast() {},
};
function setup(overrideProps) {
@@ -109,11 +113,14 @@ describe('Markdown', () => {
expect(wrapper.find(ReactMarkdown)).toExist();
});
it('should render an AceEditor when focused and editMode=true and editorMode=edit', () => {
it('should render an AceEditor when focused and editMode=true and editorMode=edit', async () => {
const wrapper = setup({ editMode: true });
expect(wrapper.find(MarkdownEditor)).not.toExist();
expect(wrapper.find(ReactMarkdown)).toExist();
wrapper.find(WithPopoverMenu).simulate('click'); // focus + edit
act(() => {
wrapper.find(WithPopoverMenu).simulate('click'); // focus + edit
});
await waitForComponentToPaint(wrapper);
expect(wrapper.find(MarkdownEditor)).toExist();
expect(wrapper.find(ReactMarkdown)).not.toExist();
});