File tree 2 files changed +35
-4
lines changed
2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { shallow } from 'enzyme' ;
3
3
4
- import Versions from './Versions' ;
4
+ describe ( '<Version /> component' , ( ) => {
5
+ beforeEach ( ( ) => {
6
+ jest . resetModules ( ) ;
7
+ } ) ;
5
8
6
- describe ( '<Versions /> component' , ( ) => {
7
9
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 /> ) ;
9
40
expect ( wrapper . html ( ) ) . toMatchSnapshot ( ) ;
10
41
} ) ;
11
42
} ) ;
Original file line number Diff line number Diff line change 1
1
// Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
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>"`;
You can’t perform that action at this time.
0 commit comments