refactor: migrate Uplinks to function component (#165)

This commit is contained in:
Antoine Chalifour
2019-10-07 14:13:05 +02:00
committed by Priscila Oliveira
parent 0ca89dcbe7
commit 950f6defca
3 changed files with 63 additions and 47 deletions

View File

@@ -1,6 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow, mount } from 'enzyme';
import { DetailContext } from '../../pages/Version';
import UpLinks from './UpLinks';
describe('<UpLinks /> component', () => {
@@ -8,4 +9,33 @@ describe('<UpLinks /> component', () => {
const wrapper = shallow(<UpLinks />);
expect(wrapper.html()).toMatchSnapshot();
});
test('should render the component with uplinks', () => {
const packageMeta = {
latest: {
name: 'verdaccio',
version: '4.0.0',
author: {
name: 'verdaccio user',
url: '',
avatar: 'https://www.gravatar.com/avatar/000000',
},
dist: { fileCount: 0, unpackedSize: 0 },
},
_uplinks: {
npmjs: {
etag: '"W/"252f0a131cedd3ea82dfefd6fa049558""',
fetched: 1529779934081,
},
},
};
const wrapper = mount(
<DetailContext.Provider value={{ packageMeta }}>
<UpLinks />
</DetailContext.Provider>
);
expect(wrapper.html()).toMatchSnapshot();
});
});