2019-04-05 02:23:40 +07:00
|
|
|
import React from 'react';
|
2019-10-07 19:13:05 +07:00
|
|
|
import { shallow, mount } from 'enzyme';
|
2019-04-05 02:23:40 +07:00
|
|
|
|
2019-10-07 19:13:05 +07:00
|
|
|
import { DetailContext } from '../../pages/Version';
|
2019-06-20 19:37:28 +07:00
|
|
|
import UpLinks from './UpLinks';
|
2019-04-05 02:23:40 +07:00
|
|
|
|
2019-06-20 19:37:28 +07:00
|
|
|
describe('<UpLinks /> component', () => {
|
2019-04-05 02:23:40 +07:00
|
|
|
test('should render the component in default state', () => {
|
2019-06-20 19:37:28 +07:00
|
|
|
const wrapper = shallow(<UpLinks />);
|
2019-04-05 02:23:40 +07:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
2019-10-07 19:13:05 +07:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
2019-04-05 02:23:40 +07:00
|
|
|
});
|