1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/webui/components/PackageSidebar/lastsync.spec.js
2018-01-07 07:59:36 +00:00

35 lines
1.1 KiB
JavaScript

/**
* LastSync component
*/
import React from 'react';
import { mount, shallow } from 'enzyme';
import LastSync from '../../../../src/webui/src/components/PackageSidebar/modules/LastSync';
import { packageMeta } from '../store/packageMeta';
jest.mock(
'../../../../src/webui/utils/datetime',
() => require('../__mocks__/datetime').default
);
console.error = jest.fn();
describe('<PackageSidebar /> : <LastSync />', () => {
it('should load the component and check getters: lastUpdate, recentReleases with package data', () => {
const wrapper = mount(<LastSync packageMeta={packageMeta} />);
const instance = wrapper.instance();
const result = [
{ time: 'Dec 14, 2017, 3:43 PM', version: '2.7.1' },
{ time: 'Dec 5, 2017, 11:25 PM', version: '2.7.0' },
{ time: 'Nov 8, 2017, 10:47 PM', version: '2.6.6' }
];
expect(instance.lastUpdate).toEqual('Dec 14, 2017, 3:43 PM');
expect(instance.recentReleases).toEqual(result);
});
it('should load the LastSync component and match snapshot', () => {
const wrapper = shallow(<LastSync packageMeta={packageMeta} />);
expect(wrapper.html()).toMatchSnapshot();
});
});