refactor: removes old package detail component

This commit is contained in:
Ayush Sharma 2019-02-05 20:56:13 +01:00
parent fed9711f48
commit 711f8153a5
4 changed files with 0 additions and 84 deletions

View File

@ -1,31 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import isNil from 'lodash/isNil';
import Readme from '../Readme';
import classes from './packageDetail.scss';
const displayState = (description) => {
return !isNil(description) ? <Readme description={description} /> : '';
};
const PackageDetail = ({packageName, readMe}) => {
return (
<div className={classes.pkgDetail}>
<h1 className={classes.title}>
{packageName}
</h1>
<div className={classes.readme}>
{displayState(readMe)}
</div>
</div>
);
};
PackageDetail.propTypes = {
readMe: PropTypes.string,
packageName: PropTypes.string.isRequired,
};
export default PackageDetail;

View File

@ -1,16 +0,0 @@
@import '../../styles/variables';
@import '../../styles/mixins';
.pkgDetail {
.title {
font-size: $font-size-xxl;
font-weight: $font-weight-semibold;
margin: 0 0 40px;
padding-bottom: 5px;
@include border-bottom-default($greyGainsboro);
}
.readme {
margin-bottom: 5em;
}
}

View File

@ -1,3 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<PackageDetail /> component should load the component 1`] = `"<div class=\\"pkgDetail\\"><h1 class=\\"title\\">Verdaccio</h1><div class=\\"readme\\"><div class=\\"markdown-body\\">Test readme</div></div></div>"`;

View File

@ -1,34 +0,0 @@
/**
* 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';
import {WEB_TITLE} from '../../../../src/lib/constants';
console.error = jest.fn();
describe('<PackageDetail /> component', () => {
test('should give error for required props', () => {
shallow(<PackageDetail />);
expect(console.error).toHaveBeenCalled();
});
test('should load the component', () => {
const props = {
readMe: 'Test readme',
packageName: WEB_TITLE
};
const wrapper = shallow(<PackageDetail {...props} />);
expect(wrapper.find('h1').text()).toEqual(WEB_TITLE);
expect(
wrapper
.find(Readme)
.dive()
.html()
).toEqual('<div class="markdown-body">Test readme</div>');
expect(wrapper.html()).toMatchSnapshot();
});
});