2020-10-25 18:48:23 +00:00
|
|
|
import {shallow} from 'enzyme';
|
|
|
|
import React from 'react';
|
|
|
|
import InfoHeaderItem from './InfoHeaderItem';
|
2020-10-19 21:12:07 +00:00
|
|
|
|
|
|
|
describe('<InfoHeaderItem/>', function () {
|
|
|
|
it('renders without crashing ', function () {
|
|
|
|
const wrapper = shallow(<InfoHeaderItem/>);
|
|
|
|
wrapper.unmount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correct text', function () {
|
|
|
|
const wrapper = shallow(<InfoHeaderItem text='mytext'/>);
|
2020-10-25 18:48:23 +00:00
|
|
|
expect(wrapper.find('.maintext').text()).toBe('mytext');
|
2020-10-19 21:12:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correct subtext', function () {
|
|
|
|
const wrapper = shallow(<InfoHeaderItem text='mimi' subtext='testtext'/>);
|
2020-10-25 18:48:23 +00:00
|
|
|
expect(wrapper.find('.subtext').text()).toBe('testtext');
|
2020-10-19 21:12:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('test no subtext if no text defined', function () {
|
|
|
|
const wrapper = shallow(<InfoHeaderItem subtext='testi'/>);
|
2020-10-25 18:48:23 +00:00
|
|
|
expect(wrapper.find('.subtext')).toHaveLength(0);
|
2020-10-19 21:12:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('test custom click handler', function () {
|
|
|
|
const func = jest.fn();
|
|
|
|
const wrapper = shallow(<InfoHeaderItem onClick={() => func()}/>);
|
|
|
|
expect(func).toBeCalledTimes(0);
|
2020-10-25 18:48:23 +00:00
|
|
|
wrapper.simulate('click');
|
2020-10-19 21:12:07 +00:00
|
|
|
expect(func).toBeCalledTimes(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('test insertion of loading spinner', function () {
|
|
|
|
const wrapper = shallow(<InfoHeaderItem text={null}/>);
|
2020-10-25 18:48:23 +00:00
|
|
|
expect(wrapper.find('Spinner').length).toBe(1);
|
2020-10-19 21:12:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('test loading spinner if undefined', function () {
|
|
|
|
const wrapper = shallow(<InfoHeaderItem/>);
|
2020-10-25 18:48:23 +00:00
|
|
|
expect(wrapper.find('Spinner').length).toBe(1);
|
2020-10-19 21:12:07 +00:00
|
|
|
});
|
|
|
|
});
|