1
1
/* eslint-disable react/jsx-filename-extension */
2
2
3
- import { mount , configure } from 'enzyme' ;
3
+ import { shallow , configure } from 'enzyme' ;
4
4
import React from 'react' ;
5
- import { act } from 'react-dom/test-utils' ;
6
5
import Adapter from 'enzyme-adapter-react-16' ;
7
6
import MainContainer from '../containers/MainContainer' ;
8
7
import { useStoreContext } from '../store' ;
@@ -18,15 +17,8 @@ const chrome = require('sinon-chrome');
18
17
configure ( { adapter : new Adapter ( ) } ) ;
19
18
20
19
const state = {
21
- tabs : {
22
- 87 : {
23
- snapshots : [ { } , { } , { } , { } ] ,
24
- sliderIndex : 0 ,
25
- viewIndex : - 1 ,
26
- mode : { } ,
27
- } ,
28
- } ,
29
- currentTab : 87 ,
20
+ tabs : { } ,
21
+ currentTab : null ,
30
22
} ;
31
23
32
24
const dispatch = jest . fn ( ) ;
@@ -49,29 +41,32 @@ const port = {
49
41
chrome . runtime . connect . returns ( port ) ;
50
42
51
43
beforeEach ( ( ) => {
52
- wrapper = mount ( < MainContainer /> ) ;
44
+ wrapper = shallow ( < MainContainer /> ) ;
53
45
useStoreContext . mockClear ( ) ;
54
46
dispatch . mockClear ( ) ;
55
47
} ) ;
56
48
57
49
describe ( 'MainContainer rendering' , ( ) => {
58
- test . skip ( 'With no connection, should not render any containers' , ( ) => {
59
- expect ( wrapper . text ( ) ) . toEqual ( 'please install our npm package in your app' ) ;
50
+ test ( 'With no snapshots, should not render any containers' , ( ) => {
51
+ expect ( wrapper . text ( ) ) . toEqual (
52
+ 'No React application found. Please install our npm package in your app.' ,
53
+ ) ;
60
54
expect ( wrapper . find ( HeadContainer ) . length ) . toBe ( 0 ) ;
61
55
expect ( wrapper . find ( ActionContainer ) . length ) . toBe ( 0 ) ;
62
56
expect ( wrapper . find ( StateContainer ) . length ) . toBe ( 0 ) ;
63
57
expect ( wrapper . find ( TravelContainer ) . length ) . toBe ( 0 ) ;
64
58
expect ( wrapper . find ( ButtonsContainer ) . length ) . toBe ( 0 ) ;
65
59
} ) ;
66
- test ( 'With connection established, should render all containers' , ( ) => {
67
- // fake connect
68
- act ( ( ) => {
69
- eventListener ( {
70
- action : 'initialConnectSnapshots' ,
71
- payload : 'test' ,
72
- } ) ;
73
- } ) ;
74
- wrapper . update ( ) ;
60
+ test ( 'With snapshots, should render all containers' , ( ) => {
61
+ state . currentTab = 87 ;
62
+ state . tabs [ 87 ] = {
63
+ snapshots : [ { } ] ,
64
+ viewIndex : - 1 ,
65
+ sliderIndex : 0 ,
66
+ mode : { } ,
67
+ } ;
68
+
69
+ wrapper = shallow ( < MainContainer /> ) ;
75
70
expect ( wrapper . find ( HeadContainer ) . length ) . toBe ( 1 ) ;
76
71
expect ( wrapper . find ( ActionContainer ) . length ) . toBe ( 1 ) ;
77
72
expect ( wrapper . find ( StateContainer ) . length ) . toBe ( 1 ) ;
0 commit comments