Cover Dashboard page with tests (#527)

* Cover Dashboard page with tests

* Cover Dashboard page with tests

* Cover Dashboard page with tests

* Cover Dashboard page with tests

* Cover Dashboard page with tests

* Cover Dashboard page with tests #527

* Cover Brokers page with tests #213
This commit is contained in:
MBovtriukProvectus 2021-06-30 12:41:53 +03:00 committed by GitHub
parent 3fa2b995c6
commit aa46749778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 0 deletions

View file

@ -0,0 +1,37 @@
import React from 'react';
import { shallow } from 'enzyme';
import ClustersWidget from 'components/Dashboard/ClustersWidget/ClustersWidget';
import { offlineCluster, onlineCluster, clusters } from './fixtures';
const component = () =>
shallow(
<ClustersWidget
clusters={clusters}
onlineClusters={[onlineCluster]}
offlineClusters={[offlineCluster]}
/>
);
describe('ClustersWidget', () => {
it('renders clusterWidget list', () => {
const clusterWidget = component().find('ClusterWidget');
expect(clusterWidget.length).toBe(2);
});
it('renders ClusterWidget', () => {
expect(component().exists('ClusterWidget')).toBeTruthy();
});
it('renders columns', () => {
expect(component().exists('.columns')).toBeTruthy();
});
it('hides online cluster widgets', () => {
const value = component();
const input = value.find('input');
expect(value.find('ClusterWidget').length).toBe(2);
input.simulate('change', { target: { checked: true } });
expect(value.find('ClusterWidget').length).toBe(1);
});
});

View file

@ -0,0 +1,18 @@
import React from 'react';
import { mount } from 'enzyme';
import { containerRendersView } from 'lib/testHelpers';
import ClustersWidget from 'components/Dashboard/ClustersWidget/ClustersWidget';
import ClustersWidgetContainer from 'components/Dashboard/ClustersWidget/ClustersWidgetContainer';
describe('ClustersWidgetContainer', () => {
containerRendersView(<ClustersWidgetContainer />, ClustersWidget);
describe('view empty ClusterWidget', () => {
const setupEmptyWrapper = () => (
<ClustersWidget clusters={[]} onlineClusters={[]} offlineClusters={[]} />
);
it(' is empty when no online clusters', () => {
const wrapper = mount(setupEmptyWrapper());
expect(wrapper.find('.is-success').text()).toBe('0');
});
});
});

View file

@ -0,0 +1,15 @@
import React from 'react';
import { shallow } from 'enzyme';
import Dashboard from 'components/Dashboard/Dashboard';
const component = shallow(<Dashboard />);
describe('Dashboard', () => {
it('renders section', () => {
expect(component.exists('.section')).toBe(true);
});
it('renders ClustersWidget', () => {
expect(component.exists('Connect(ClustersWidget)')).toBe(true);
});
});