mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
3639557118
* feat: added material-ui refactor: replaced element-react by material-ui refactor: updated snapshots refactor: updated tests * fix: modified validation.WIP * refactor: modified tests.WIP * test(fix): unit test for login and validat ecredentials * chore(fix): e2e update css selectors * test(fix): replace Object.values by supported syntax on node6
75 lines
2.0 KiB
JavaScript
75 lines
2.0 KiB
JavaScript
/**
|
|
* Package component
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import Package from '../../../../src/webui/components/Package/index';
|
|
import { BrowserRouter } from 'react-router-dom';
|
|
import Chip from '@material-ui/core/Chip';
|
|
|
|
/**
|
|
* Generates one month back date from current time
|
|
* @return {object} date object
|
|
*/
|
|
const dateOneMonthAgo = () => {
|
|
const date = new Date();
|
|
date.setMonth(date.getMonth() - 1);
|
|
return date;
|
|
}
|
|
|
|
describe('<Package /> component', () => {
|
|
it('should load the component', () => {
|
|
const props = {
|
|
name: 'verdaccio',
|
|
version: '1.0.0',
|
|
time: dateOneMonthAgo(),
|
|
license: 'MIT',
|
|
description: 'Private NPM repository',
|
|
author: 'Sam'
|
|
};
|
|
const wrapper = mount(
|
|
<BrowserRouter>
|
|
<Package {...props} />
|
|
</BrowserRouter>
|
|
);
|
|
|
|
const version =
|
|
wrapper.findWhere(node => node.is(Chip) && node.prop('label') === 'v1.0.0');
|
|
|
|
// integration expectations
|
|
expect(wrapper.find('a').prop('href')).toEqual('detail/verdaccio');
|
|
expect(wrapper.find('h1').text()).toEqual('verdaccio v1.0.0');
|
|
expect(version.exists()).toBe(true);
|
|
expect(
|
|
wrapper.find('div').filterWhere(n => n.prop('role') === 'author')
|
|
.text()
|
|
).toEqual('By: Sam');
|
|
expect(wrapper.find('p').text()).toEqual('Private NPM repository');
|
|
expect(wrapper.find('.license').text()).toMatch(/MIT/);
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
});
|
|
|
|
it('should load the component without author', () => {
|
|
const props = {
|
|
name: 'verdaccio',
|
|
version: '1.0.0',
|
|
time: dateOneMonthAgo(),
|
|
license: 'MIT',
|
|
description: 'Private NPM repository'
|
|
};
|
|
const wrapper = mount(
|
|
<BrowserRouter>
|
|
<Package {...props} />
|
|
</BrowserRouter>
|
|
);
|
|
|
|
// integration expectations
|
|
expect(
|
|
wrapper.find('div').filterWhere(n => n.prop('role') === 'author')
|
|
.text()
|
|
).toEqual('');
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
});
|
|
});
|