2017-12-19 23:10:53 -05:00
|
|
|
/**
|
|
|
|
* LastSync component
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { mount, shallow } from 'enzyme';
|
2018-06-17 06:34:59 -05:00
|
|
|
import LastSync from '../../../../../src/webui/src/components/PackageSidebar/modules/LastSync/index';
|
2017-12-19 23:10:53 -05:00
|
|
|
import { packageMeta } from '../store/packageMeta';
|
|
|
|
|
|
|
|
console.error = jest.fn();
|
|
|
|
|
2018-03-21 06:26:27 -05:00
|
|
|
describe('<PackageSidebar /> : <LastSync />', () => {
|
2017-12-19 23:10:53 -05:00
|
|
|
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 = [
|
2018-03-21 06:26:27 -05:00
|
|
|
{ time: '2017/12/14, 15:43:27', version: '2.7.1' },
|
|
|
|
{ time: '2017/12/05, 23:25:06', version: '2.7.0' },
|
|
|
|
{ time: '2017/11/08, 22:47:16', version: '2.6.6' }
|
2017-12-19 23:10:53 -05:00
|
|
|
];
|
2018-03-21 06:26:27 -05:00
|
|
|
const lastUpdated = '2017/12/14, 15:43:52';
|
|
|
|
expect(instance.lastUpdate).toEqual(lastUpdated);
|
2017-12-19 23:10:53 -05:00
|
|
|
expect(instance.recentReleases).toEqual(result);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should load the LastSync component and match snapshot', () => {
|
|
|
|
const wrapper = shallow(<LastSync packageMeta={packageMeta} />);
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|