
* Removed two enzyme test with testing-library tests * Got rid of enzyme and wrapper in List.spec.tsx * Got rid of enzyme and wrapper in ListItem.spec.tsx * Got rid of enzyme and wrapper in BytesFormatted.spec.tsx * Got rid of enzyme and wrapper in ConfirmationModal.spec.tsx * Got rid of enzyme and wrapper in Tabs.spec.tsx * Got rid of enzyme and wrapper in Actions.spec.tsx * Got rid of enzyme and wrapper in ListItem.spec.tsx * Got rid of enzyme and wrapper in FiltersContainer.spec.tsx * Got rid of enzyme and wrapper in ListItem.spec.tsx * Got rid of Enzyme in a two more files * Got rid of Enzyme in testHelpers.tsx * Got rid of snapshots * Three wrappers replaced with render from testHelpers * Testing id replaced * Fixed linter warnings * Got rid of testIds * Got rid of unnecessary containers and ...queryBy functions * Got rid of dublicated ...getByRole functions * Got rid of dublicated more than two times ...getByText functions * Got rid of unused imports * Got rid of unused import * Desciptions fixed * Got rid of providers * Got rid of unused imports * package-lock.json reverted * Refactor Actions component specs * Get rid of TestRouterWrapper * Refactor specs * Refactor specs * linting Co-authored-by: k.morozov <k.morozov@ffin.ru> Co-authored-by: lazzy-panda <grifx.design@gmail.com>
122 lines
3.2 KiB
TypeScript
122 lines
3.2 KiB
TypeScript
import React from 'react';
|
|
import { Route } from 'react-router-dom';
|
|
import { render } from 'lib/testHelpers';
|
|
import { clusterConnectConnectorPath } from 'lib/paths';
|
|
import Details, { DetailsProps } from 'components/Connect/Details/Details';
|
|
import { connector, tasks } from 'redux/reducers/connect/__test__/fixtures';
|
|
import { screen } from '@testing-library/dom';
|
|
|
|
jest.mock(
|
|
'components/Connect/Details/Overview/OverviewContainer',
|
|
() => 'mock-OverviewContainer'
|
|
);
|
|
|
|
jest.mock(
|
|
'components/Connect/Details/Tasks/TasksContainer',
|
|
() => 'mock-TasksContainer'
|
|
);
|
|
|
|
jest.mock(
|
|
'components/Connect/Details/Config/ConfigContainer',
|
|
() => 'mock-ConfigContainer'
|
|
);
|
|
|
|
jest.mock(
|
|
'components/Connect/Details/Actions/ActionsContainer',
|
|
() => 'mock-ActionsContainer'
|
|
);
|
|
|
|
describe('Details', () => {
|
|
const pathname = clusterConnectConnectorPath(
|
|
':clusterName',
|
|
':connectName',
|
|
':connectorName'
|
|
);
|
|
const clusterName = 'my-cluster';
|
|
const connectName = 'my-connect';
|
|
const connectorName = 'my-connector';
|
|
|
|
const setupWrapper = (props: Partial<DetailsProps> = {}) => (
|
|
<Route path={pathname}>
|
|
<Details
|
|
fetchConnector={jest.fn()}
|
|
fetchTasks={jest.fn()}
|
|
isConnectorFetching={false}
|
|
areTasksFetching={false}
|
|
connector={connector}
|
|
tasks={tasks}
|
|
{...props}
|
|
/>
|
|
</Route>
|
|
);
|
|
|
|
it('renders progressbar when fetching connector', () => {
|
|
render(setupWrapper({ isConnectorFetching: true }), {
|
|
pathname: clusterConnectConnectorPath(
|
|
clusterName,
|
|
connectName,
|
|
connectorName
|
|
),
|
|
});
|
|
|
|
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('renders progressbar when fetching tasks', () => {
|
|
render(setupWrapper({ areTasksFetching: true }), {
|
|
pathname: clusterConnectConnectorPath(
|
|
clusterName,
|
|
connectName,
|
|
connectorName
|
|
),
|
|
});
|
|
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('is empty when no connector', () => {
|
|
const { container } = render(setupWrapper({ connector: null }), {
|
|
pathname: clusterConnectConnectorPath(
|
|
clusterName,
|
|
connectName,
|
|
connectorName
|
|
),
|
|
});
|
|
expect(container).toBeEmptyDOMElement();
|
|
});
|
|
|
|
it('fetches connector on mount', () => {
|
|
const fetchConnector = jest.fn();
|
|
render(setupWrapper({ fetchConnector }), {
|
|
pathname: clusterConnectConnectorPath(
|
|
clusterName,
|
|
connectName,
|
|
connectorName
|
|
),
|
|
});
|
|
expect(fetchConnector).toHaveBeenCalledTimes(1);
|
|
expect(fetchConnector).toHaveBeenCalledWith({
|
|
clusterName,
|
|
connectName,
|
|
connectorName,
|
|
});
|
|
});
|
|
|
|
it('fetches tasks on mount', () => {
|
|
const fetchTasks = jest.fn();
|
|
render(setupWrapper({ fetchTasks }), {
|
|
pathname: clusterConnectConnectorPath(
|
|
clusterName,
|
|
connectName,
|
|
connectorName
|
|
),
|
|
});
|
|
expect(fetchTasks).toHaveBeenCalledTimes(1);
|
|
expect(fetchTasks).toHaveBeenCalledWith({
|
|
clusterName,
|
|
connectName,
|
|
connectorName,
|
|
});
|
|
});
|
|
});
|