0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-13 22:48:31 -05:00
verdaccio/test/unit/webui/components/packagedetail.spec.js

35 lines
956 B
JavaScript
Raw Normal View History

2017-11-30 22:01:25 +05:30
/**
* PackageDetail component
*/
import React from 'react';
import { shallow } from 'enzyme';
import PackageDetail from '../../../../src/webui/components/PackageDetail/index';
import Readme from '../../../../src/webui/components/Readme/index';
2018-06-28 18:33:37 +02:00
import {WEB_TITLE} from '../../../../src/lib/constants';
2017-11-30 22:01:25 +05:30
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',
packageName: WEB_TITLE
2017-11-30 22:01:25 +05:30
};
const wrapper = shallow(<PackageDetail {...props} />);
2017-12-02 00:34:01 +05:30
2018-06-28 18:33:37 +02:00
expect(wrapper.find('h1').text()).toEqual(WEB_TITLE);
2017-12-02 00:34:01 +05:30
expect(
wrapper
.find(Readme)
.dive()
.html()
).toEqual('<div class="markdown-body">Test readme</div>');
expect(wrapper.html()).toMatchSnapshot();
2017-11-30 22:01:25 +05:30
});
});