1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-17 07:45:52 +01:00
verdaccio/test/unit/webui/components/PackageSidebar/maintainers.spec.js
2018-12-15 16:39:51 +01:00

78 lines
2.2 KiB
JavaScript

/**
* Maintainers component
*/
import React from 'react';
import { mount } from 'enzyme';
import Maintainers from '../../../../../src/webui/components/PackageSidebar/modules/Maintainers/index';
import { packageMeta } from '../store/packageMeta';
describe('<PackageSidebar /> : <Maintainers />', () => {
let wrapper;
let instance;
beforeEach(() => {
wrapper = mount(<Maintainers packageMeta={packageMeta} />);
instance = wrapper.instance();
});
test('should match with the props', () => {
expect(wrapper.props().packageMeta).toEqual(packageMeta);
expect(wrapper.html()).toMatchSnapshot();
});
test('author shoule be equal to User NPM', () => {
expect(instance.author).toEqual({
avatar:
'https://www.gravatar.com/avatar/a5a236ba477ee98908600c40cda74f4a',
email: 'test@author.local',
name: 'User NPM'
});
});
test('should get all the contributors with false for showAllContributors', () => {
expect(instance.showAllContributors).toBeFalsy();
});
test('should get unique contributors', () => {
const result = [
{
avatar:
'https://www.gravatar.com/avatar/4ef03c2bf8d8689527903212d96fb45b',
email: 'test1@test.local',
name: '030'
},
{
avatar:
'https://www.gravatar.com/avatar/06975001f7f2be7052bcf978700c6112',
email: 'tes4@test.local',
name: 'Alex Vernacchia'
},
{
avatar:
'https://www.gravatar.com/avatar/d9acfc4ed4e49a436738ff26a722dce4',
email: 'test5@test.local',
name: 'Alexander Makarenko'
},
{
avatar:
'https://www.gravatar.com/avatar/2e095c7cfd278f72825d0fed6e12e3b1',
email: 'test6@test.local',
name: 'Alexandre-io'
},
{
avatar:
'https://www.gravatar.com/avatar/371edff6d79c39bb9e36bde39d41a4b0',
email: 'test7@test.local',
name: 'Aram Drevekenin'
}
];
expect(instance.uniqueContributors).toEqual(result);
});
test('should click on handleShowAllContributors', () => {
wrapper.find('button').simulate('click');
expect(wrapper.state('showAllContributors')).toBeTruthy();
});
});