|
@@ -1,9 +1,11 @@
|
|
import React from 'react';
|
|
import React from 'react';
|
|
import { shallow } from 'enzyme';
|
|
import { shallow } from 'enzyme';
|
|
|
|
+import { screen } from '@testing-library/react';
|
|
|
|
+import { render } from 'lib/testHelpers';
|
|
import Overview from 'components/Topics/Topic/Details/Overview/Overview';
|
|
import Overview from 'components/Topics/Topic/Details/Overview/Overview';
|
|
|
|
+import theme from 'theme/theme';
|
|
|
|
|
|
describe('Overview', () => {
|
|
describe('Overview', () => {
|
|
- const mockInternal = false;
|
|
|
|
const mockClusterName = 'local';
|
|
const mockClusterName = 'local';
|
|
const mockTopicName = 'topic';
|
|
const mockTopicName = 'topic';
|
|
const mockClearTopicMessages = jest.fn();
|
|
const mockClearTopicMessages = jest.fn();
|
|
@@ -23,13 +25,32 @@ describe('Overview', () => {
|
|
},
|
|
},
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+ const renderComponent = ({
|
|
|
|
+ underReplicatedPartitions = 1,
|
|
|
|
+ inSyncReplicas = 1,
|
|
|
|
+ replicas = 1,
|
|
|
|
+ } = {}) =>
|
|
|
|
+ render(
|
|
|
|
+ <Overview
|
|
|
|
+ name={mockTopicName}
|
|
|
|
+ partitions={mockPartitions}
|
|
|
|
+ internal={undefined}
|
|
|
|
+ clusterName={mockClusterName}
|
|
|
|
+ topicName={mockTopicName}
|
|
|
|
+ clearTopicMessages={mockClearTopicMessages}
|
|
|
|
+ underReplicatedPartitions={underReplicatedPartitions}
|
|
|
|
+ inSyncReplicas={inSyncReplicas}
|
|
|
|
+ replicas={replicas}
|
|
|
|
+ />
|
|
|
|
+ );
|
|
|
|
+
|
|
describe('when it has internal flag', () => {
|
|
describe('when it has internal flag', () => {
|
|
it('does not render the Action button a Topic', () => {
|
|
it('does not render the Action button a Topic', () => {
|
|
const component = shallow(
|
|
const component = shallow(
|
|
<Overview
|
|
<Overview
|
|
name={mockTopicName}
|
|
name={mockTopicName}
|
|
partitions={mockPartitions}
|
|
partitions={mockPartitions}
|
|
- internal={mockInternal}
|
|
|
|
|
|
+ internal={false}
|
|
clusterName={mockClusterName}
|
|
clusterName={mockClusterName}
|
|
topicName={mockTopicName}
|
|
topicName={mockTopicName}
|
|
clearTopicMessages={mockClearTopicMessages}
|
|
clearTopicMessages={mockClearTopicMessages}
|
|
@@ -44,7 +65,7 @@ describe('Overview', () => {
|
|
<Overview
|
|
<Overview
|
|
name={mockTopicName}
|
|
name={mockTopicName}
|
|
partitions={[]}
|
|
partitions={[]}
|
|
- internal={mockInternal}
|
|
|
|
|
|
+ internal
|
|
clusterName={mockClusterName}
|
|
clusterName={mockClusterName}
|
|
topicName={mockTopicName}
|
|
topicName={mockTopicName}
|
|
clearTopicMessages={mockClearTopicMessages}
|
|
clearTopicMessages={mockClearTopicMessages}
|
|
@@ -54,4 +75,27 @@ describe('Overview', () => {
|
|
expect(componentEmpty.find('td').text()).toEqual('No Partitions found');
|
|
expect(componentEmpty.find('td').text()).toEqual('No Partitions found');
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ describe('should render circular alert', () => {
|
|
|
|
+ it('should be in document', () => {
|
|
|
|
+ renderComponent();
|
|
|
|
+ const circles = screen.getAllByRole('circle');
|
|
|
|
+ expect(circles.length).toEqual(2);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should be the appropriate color', () => {
|
|
|
|
+ renderComponent({
|
|
|
|
+ underReplicatedPartitions: 0,
|
|
|
|
+ inSyncReplicas: 1,
|
|
|
|
+ replicas: 2,
|
|
|
|
+ });
|
|
|
|
+ const circles = screen.getAllByRole('circle');
|
|
|
|
+ expect(circles[0]).toHaveStyle(
|
|
|
|
+ `fill: ${theme.circularAlert.color.error}`
|
|
|
|
+ );
|
|
|
|
+ expect(circles[1]).toHaveStyle(
|
|
|
|
+ `fill: ${theme.circularAlert.color.error}`
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ });
|
|
});
|
|
});
|