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:
parent
3fa2b995c6
commit
aa46749778
3 changed files with 70 additions and 0 deletions
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue