mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
5ae7863d8f
deps fixes for ui tests snapshot fixes
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
/**
|
|
* Package component
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import Package from '../../../src/webui/src/components/Package';
|
|
import { BrowserRouter } from 'react-router-dom';
|
|
|
|
describe('<Package /> component', () => {
|
|
it('should load the component', () => {
|
|
const props = {
|
|
name: 'verdaccio',
|
|
version: '1.0.0',
|
|
description: 'Private NPM repository',
|
|
author: { name: 'Sam' }
|
|
};
|
|
const wrapper = mount(
|
|
<BrowserRouter>
|
|
<Package package={props} />
|
|
</BrowserRouter>
|
|
);
|
|
|
|
// renderAuthor method
|
|
const renderAuthor = wrapper.find(Package).instance().renderAuthor;
|
|
expect(renderAuthor({ author: {} })).toBeUndefined();
|
|
expect(renderAuthor({ author: { name: 'sam' } })).toBeDefined();
|
|
|
|
// integration expectations
|
|
expect(wrapper.find('a').prop('href')).toEqual('detail/verdaccio');
|
|
expect(wrapper.find('h1').text()).toEqual('verdacciov1.0.0');
|
|
expect(wrapper.find('.el-tag--gray').text()).toEqual('v1.0.0');
|
|
expect(
|
|
wrapper
|
|
.find('span')
|
|
.filterWhere(n => n.prop('role') === 'author')
|
|
.text()
|
|
).toEqual('By: Sam');
|
|
expect(wrapper.find('p').text()).toEqual('Private NPM repository');
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
});
|
|
});
|