2017-11-30 11:31:25 -05:00
|
|
|
/**
|
|
|
|
* PackageDetail component
|
|
|
|
*/
|
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2018-06-17 06:34:59 -05:00
|
|
|
import PackageDetail from '../../../../src/webui/src/components/PackageDetail/index';
|
|
|
|
import Readme from '../../../../src/webui/src/components/Readme/index';
|
2018-06-28 11:33:37 -05:00
|
|
|
import {WEB_TITLE} from '../../../../src/lib/constants';
|
2017-11-30 11:31:25 -05:00
|
|
|
|
|
|
|
console.error = jest.fn();
|
|
|
|
|
|
|
|
describe('<PackageDetail /> component', () => {
|
|
|
|
it('should give error for required props', () => {
|
|
|
|
shallow(<PackageDetail />);
|
|
|
|
expect(console.error).toBeCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should load the component', () => {
|
|
|
|
const props = {
|
|
|
|
readMe: 'Test readme',
|
2018-06-28 11:33:37 -05:00
|
|
|
package: WEB_TITLE
|
2017-11-30 11:31:25 -05:00
|
|
|
};
|
|
|
|
const wrapper = shallow(<PackageDetail {...props} />);
|
2017-12-01 14:04:01 -05:00
|
|
|
|
2018-06-28 11:33:37 -05:00
|
|
|
expect(wrapper.find('h1').text()).toEqual(WEB_TITLE);
|
2017-12-01 14:04:01 -05:00
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find(Readme)
|
|
|
|
.dive()
|
|
|
|
.html()
|
|
|
|
).toEqual('<div class="markdown-body">Test readme</div>');
|
2017-12-02 09:01:06 -05:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
2017-11-30 11:31:25 -05:00
|
|
|
});
|
|
|
|
});
|