2019-04-05 02:23:40 +07:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import { BrowserRouter } from 'react-router-dom';
|
|
|
|
|
2019-10-08 03:19:18 +07:00
|
|
|
import Help from '../Help';
|
|
|
|
|
2019-10-26 16:36:16 +07:00
|
|
|
import { PackageList } from './PackageList';
|
2019-10-08 03:19:18 +07:00
|
|
|
|
2019-04-05 02:23:40 +07:00
|
|
|
describe('<PackageList /> component', () => {
|
|
|
|
test('should load the component with no packages', () => {
|
|
|
|
const props = {
|
|
|
|
packages: [],
|
|
|
|
};
|
2019-06-20 19:37:28 +07:00
|
|
|
const wrapper = mount(<PackageList packages={props.packages} />);
|
2019-04-05 02:23:40 +07:00
|
|
|
expect(wrapper.find(Help).exists()).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should load the component with packages', () => {
|
|
|
|
const props = {
|
|
|
|
packages: [
|
|
|
|
{
|
|
|
|
name: 'verdaccio',
|
|
|
|
version: '1.0.0',
|
|
|
|
time: new Date(1532211072138).getTime(),
|
|
|
|
description: 'Private NPM repository',
|
2019-06-20 19:37:28 +07:00
|
|
|
author: { name: 'Sam', avatar: 'test avatar' },
|
2019-04-05 02:23:40 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'abc',
|
|
|
|
version: '1.0.1',
|
|
|
|
time: new Date(1532211072138).getTime(),
|
|
|
|
description: 'abc description',
|
2019-06-20 19:37:28 +07:00
|
|
|
author: { name: 'Rose', avatar: 'test avatar' },
|
2019-04-05 02:23:40 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'xyz',
|
|
|
|
version: '1.1.0',
|
|
|
|
description: 'xyz description',
|
2019-06-20 19:37:28 +07:00
|
|
|
author: { name: 'Martin', avatar: 'test avatar' },
|
|
|
|
},
|
2019-04-05 02:23:40 +07:00
|
|
|
],
|
2019-06-20 19:37:28 +07:00
|
|
|
help: false,
|
2019-04-05 02:23:40 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(
|
|
|
|
<BrowserRouter>
|
2019-06-20 19:37:28 +07:00
|
|
|
<PackageList packages={props.packages} />
|
2019-04-05 02:23:40 +07:00
|
|
|
</BrowserRouter>
|
|
|
|
);
|
|
|
|
|
|
|
|
// package count
|
|
|
|
expect(wrapper.find('Package')).toHaveLength(3);
|
|
|
|
});
|
|
|
|
});
|