refactor: Replace react-bootstrap MenuItems with Antd Menu (#11555)

* Remove MenuItem from SubMenu

* Fix tests

* Refactor PopoverDropdown

* Refactor Button

* Remove redundant Menu import
This commit is contained in:
Kamil Gabryjelski
2020-11-04 23:32:38 +01:00
committed by GitHub
parent ef7087adb6
commit 3e35ddd609
8 changed files with 78 additions and 38 deletions

View File

@@ -19,7 +19,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { shallow } from 'enzyme';
import { Navbar, MenuItem } from 'react-bootstrap';
import { Navbar } from 'react-bootstrap';
import SubMenu from 'src/components/Menu/SubMenu';
const defaultProps = {
@@ -66,7 +66,7 @@ describe('SubMenu', () => {
});
it('renders 3 MenuItems (when usesRouter === false)', () => {
expect(wrapper.find(MenuItem)).toHaveLength(3);
expect(wrapper.find('li')).toHaveLength(3);
});
it('renders the menu title', () => {
@@ -83,7 +83,7 @@ describe('SubMenu', () => {
expect(routerWrapper.find(Link)).toExist();
expect(routerWrapper.find(Link)).toHaveLength(2);
expect(routerWrapper.find(MenuItem)).toHaveLength(1);
expect(routerWrapper.find('li.no-router')).toHaveLength(1);
});
it('renders buttons in the right nav of the submenu', () => {

View File

@@ -18,7 +18,7 @@
*/
import React from 'react';
import { Provider } from 'react-redux';
import { mount } from 'enzyme';
import { styledMount as mount } from 'spec/helpers/theming';
import sinon from 'sinon';
import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';

View File

@@ -18,7 +18,7 @@
*/
import { Provider } from 'react-redux';
import React from 'react';
import { mount } from 'enzyme';
import { styledMount as mount } from 'spec/helpers/theming';
import sinon from 'sinon';
import ReactMarkdown from 'react-markdown';

View File

@@ -69,10 +69,10 @@ describe('DashboardTable', () => {
it('render a submenu with clickable tabs and buttons', async () => {
expect(wrapper.find(SubMenu)).toExist();
expect(wrapper.find('MenuItem')).toHaveLength(2);
expect(wrapper.find('li')).toHaveLength(2);
expect(wrapper.find('Button')).toHaveLength(4);
act(() => {
wrapper.find('MenuItem').at(1).simulate('click');
wrapper.find('li').at(1).simulate('click');
});
await waitForComponentToPaint(wrapper);
expect(fetchMock.calls(/dashboard\/\?q/)).toHaveLength(1);

View File

@@ -89,10 +89,10 @@ describe('SavedQueries', () => {
it('it renders a submenu with clickable tables and buttons', async () => {
expect(wrapper.find(SubMenu)).toExist();
expect(wrapper.find('MenuItem')).toHaveLength(2);
expect(wrapper.find('li')).toHaveLength(2);
expect(wrapper.find('button')).toHaveLength(2);
act(() => {
wrapper.find('MenuItem').at(1).simulate('click');
wrapper.find('li').at(1).simulate('click');
});
await waitForComponentToPaint(wrapper);