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