2017-11-30 14:14:40 +01:00
|
|
|
/**
|
|
|
|
* PackageList component
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
2018-07-17 21:22:44 +02:00
|
|
|
import PackageList from '../../../../src/webui/components/PackageList/index';
|
2017-11-30 14:14:40 +01:00
|
|
|
import { BrowserRouter } from 'react-router-dom';
|
|
|
|
|
|
|
|
describe('<PackageList /> component', () => {
|
|
|
|
it('should load the component with no packages', () => {
|
|
|
|
const props = {
|
|
|
|
packages: [],
|
|
|
|
help: true
|
|
|
|
};
|
|
|
|
const wrapper = mount(
|
|
|
|
<PackageList packages={props.packages} help={props.help} />
|
|
|
|
);
|
2018-10-27 21:19:45 +02:00
|
|
|
expect(wrapper.find('Help')).toHaveLength(1);
|
|
|
|
|
|
|
|
expect(wrapper.find('h1').text()).toEqual('No Package Published Yet');
|
2017-11-30 14:14:40 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should load the component with packages', () => {
|
|
|
|
const props = {
|
|
|
|
packages: [
|
|
|
|
{
|
|
|
|
name: 'verdaccio',
|
|
|
|
version: '1.0.0',
|
2018-06-20 21:07:32 +02:00
|
|
|
time: new Date(),
|
2017-11-30 14:14:40 +01:00
|
|
|
description: 'Private NPM repository',
|
|
|
|
author: { name: 'Sam' }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'abc',
|
|
|
|
version: '1.0.1',
|
2018-06-20 21:07:32 +02:00
|
|
|
time: new Date(),
|
2017-11-30 14:14:40 +01:00
|
|
|
description: 'abc description',
|
|
|
|
author: { name: 'Rose' }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'xyz',
|
|
|
|
version: '1.1.0',
|
|
|
|
description: 'xyz description',
|
|
|
|
author: { name: 'Martin' }
|
|
|
|
}
|
|
|
|
],
|
|
|
|
help: false
|
|
|
|
};
|
2018-10-27 21:19:45 +02:00
|
|
|
|
2017-11-30 14:14:40 +01:00
|
|
|
const wrapper = mount(
|
|
|
|
<BrowserRouter>
|
|
|
|
<PackageList packages={props.packages} help={props.help} />
|
|
|
|
</BrowserRouter>
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2018-10-27 21:19:45 +02:00
|
|
|
expect(wrapper.find('.listTitle').text()).toContain('Available Packages');
|
|
|
|
|
2017-11-30 14:14:40 +01:00
|
|
|
// package count
|
|
|
|
expect(wrapper.find('Package')).toHaveLength(3);
|
2017-12-02 15:01:06 +01:00
|
|
|
// match snapshot
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
2017-11-30 14:14:40 +01:00
|
|
|
});
|
|
|
|
});
|