Skip to content

Commit e7d3c46

Browse files
authored
Merge pull request conventional-changelog#120 from verdaccio/adds-unit-test-for-version-component
chore: adds unit test for version component
2 parents d81b610 + 003f879 commit e7d3c46

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed
+34-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
11
import React from 'react';
22
import { shallow } from 'enzyme';
33

4-
import Versions from './Versions';
4+
describe('<Version /> component', () => {
5+
beforeEach(() => {
6+
jest.resetModules();
7+
});
58

6-
describe('<Versions /> component', () => {
79
test('should render the component in default state', () => {
8-
const wrapper = shallow(<Versions />);
10+
const packageMeta = {
11+
versions: {
12+
'1.0.0': {
13+
version: '1.0.0',
14+
},
15+
'2.0.0': {
16+
version: '2.0.0',
17+
},
18+
'3.0.0': {
19+
version: '3.0.0',
20+
},
21+
},
22+
time: {
23+
'1.0.0': '2016-08-26T22:36:41.762Z',
24+
'2.0.0': '2017-08-26T22:36:41.762Z',
25+
'3.0.0': '2018-02-07T06:43:22.801Z',
26+
},
27+
'dist-tags': {
28+
latest: '3.0.0',
29+
},
30+
};
31+
32+
jest.doMock('../../pages/version/Version', () => ({
33+
DetailContextConsumer: component => {
34+
return component.children({ packageMeta });
35+
},
36+
}));
37+
38+
const Version = require('./Versions').default;
39+
const wrapper = shallow(<Version />);
940
expect(wrapper.html()).toMatchSnapshot();
1041
});
1142
});
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`<Versions /> component should render the component in default state 1`] = `""`;
3+
exports[`<Version /> component should render the component in default state 1`] = `"<h3 class=\\"MuiTypography-root-1 MuiTypography-subheading-8 css-1ikpjfo e1h4if9v0\\">Current Tags</h3><ul class=\\"MuiList-root-37 MuiList-padding-38\\"><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">latest</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">3.0.0</span></div></li></ul><h3 class=\\"MuiTypography-root-1 MuiTypography-subheading-8 css-1ikpjfo e1h4if9v0\\">Version History</h3><ul class=\\"MuiList-root-37 MuiList-padding-38\\"><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">3.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">over 1 year ago</span></div></li><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">2.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">almost 2 years ago</span></div></li><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 version-item\\"><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">1.0.0</span></div><div class=\\"css-1l1cv61 e1h4if9v1\\"></div><div class=\\"MuiListItemText-root-53 css-5tz9yo e1h4if9v2\\"><span class=\\"MuiTypography-root-1 MuiTypography-subheading-8 MuiListItemText-primary-56\\">almost 3 years ago</span></div></li></ul>"`;

0 commit comments

Comments
 (0)