0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/unit/webui/components/PackageSidebar/packageSidebar.spec.js
Juan Picado @jotadeveloper 49c6191bb5
refactor: relocate unit test
no logic change, just path updates
2018-06-23 20:57:12 +02:00

35 lines
1.1 KiB
JavaScript

/**
* Package Sidebar module
*/
import React from 'react';
import { mount } from 'enzyme';
import PackageSidebar from '../../../../../src/webui/src/components/PackageSidebar/index';
import { packageMeta } from '../store/packageMeta';
jest.mock('../../../../../src/webui/utils/api', () => ({
request: require('../__mocks__/api').default.request,
}));
console.error = jest.fn();
describe('<PackageSidebar /> component', () => {
it('should throw error for the required props', () => {
const wrapper = mount(<PackageSidebar />);
const { loadPackageData } = wrapper.instance();
expect(console.error).toBeCalled();
loadPackageData().catch(response => {
expect(response).toBeUndefined();
expect(wrapper.state()).toEqual({ failed: true });
});
});
it('should load the packageMeta', () => {
const wrapper = mount(<PackageSidebar packageName={'verdaccio'} />);
const { loadPackageData } = wrapper.instance();
loadPackageData('verdaccio').then(response => {
expect(wrapper.state('packageMeta')).toEqual(packageMeta);
});
expect(wrapper.html()).toMatchSnapshot();
});
});