2019-04-05 02:23:40 +07:00
|
|
|
import React from 'react';
|
2019-08-31 16:02:46 +07:00
|
|
|
import { mount } from 'enzyme';
|
2019-04-05 02:23:40 +07:00
|
|
|
|
2019-08-31 16:02:46 +07:00
|
|
|
import Versions from './Versions';
|
2019-04-05 02:23:40 +07:00
|
|
|
|
2019-08-31 16:02:46 +07:00
|
|
|
const mockPackageMeta = jest.fn(() => ({
|
|
|
|
latest: {
|
|
|
|
versions: {
|
|
|
|
'1.0.0': {
|
|
|
|
version: '1.0.0',
|
2019-08-24 21:57:51 +07:00
|
|
|
},
|
2019-08-31 16:02:46 +07:00
|
|
|
'2.0.0': {
|
|
|
|
version: '2.0.0',
|
2019-08-24 21:57:51 +07:00
|
|
|
},
|
2019-08-31 16:02:46 +07:00
|
|
|
'3.0.0': {
|
|
|
|
version: '3.0.0',
|
2019-08-24 21:57:51 +07:00
|
|
|
},
|
2019-08-31 16:02:46 +07:00
|
|
|
},
|
|
|
|
time: {
|
|
|
|
'1.0.0': '2016-08-26T22:36:41.762Z',
|
|
|
|
'2.0.0': '2017-08-26T22:36:41.762Z',
|
|
|
|
'3.0.0': '2018-02-07T06:43:22.801Z',
|
|
|
|
},
|
|
|
|
'dist-tags': {
|
|
|
|
latest: '3.0.0',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}));
|
2019-08-24 21:57:51 +07:00
|
|
|
|
2019-08-31 16:02:46 +07:00
|
|
|
jest.mock('../../pages/Version', () => ({
|
|
|
|
DetailContextConsumer: component => {
|
|
|
|
return component.children({ packageMeta: mockPackageMeta() });
|
|
|
|
},
|
|
|
|
}));
|
2019-08-24 21:57:51 +07:00
|
|
|
|
2019-08-31 16:02:46 +07:00
|
|
|
describe('<Version /> component', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.resetModules();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should render the component in default state', () => {
|
|
|
|
const wrapper = mount(<Versions />);
|
2019-04-05 02:23:40 +07:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|