1
1
/* eslint-disable react/jsx-filename-extension */
2
2
3
3
import { shallow , configure } from 'enzyme' ;
4
- import React from 'react' ;
4
+ import React , { useState } from 'react' ;
5
5
import Adapter from 'enzyme-adapter-react-16' ;
6
6
import MainContainer from '../containers/MainContainer' ;
7
7
import { useStoreContext } from '../store' ;
8
- import {
9
- addNewSnapshots , initialConnect , setPort
10
- } from '../actions/actions' ;
8
+
11
9
import HeadContainer from '../containers/HeadContainer' ;
12
10
import ActionContainer from '../containers/ActionContainer' ;
13
11
import StateContainer from '../containers/StateContainer' ;
14
12
import TravelContainer from '../containers/TravelContainer' ;
15
13
import ButtonsContainer from '../containers/ButtonsContainer' ;
16
- import Action from '../components/Action' ;
14
+
15
+ const chrome = require ( 'sinon-chrome' ) ;
17
16
18
17
configure ( { adapter : new Adapter ( ) } ) ;
19
18
@@ -29,27 +28,34 @@ const state = {
29
28
} ;
30
29
31
30
const dispatch = jest . fn ( ) ;
32
-
33
31
jest . mock ( '../store' ) ;
34
32
useStoreContext . mockImplementation ( ( ) => [ state , dispatch ] ) ;
35
33
36
34
let wrapper ;
35
+ // global.chrome = chrome;
36
+ const setnpm = jest . fn ( ) ;
37
+
38
+
37
39
38
40
beforeEach ( ( ) => {
39
41
wrapper = shallow ( < MainContainer /> ) ;
42
+ chrome . runtime . connect = ( ) => { }
43
+ console . log ( chrome . runtime . connect ) ;
44
+ chrome . runtime . onMessage . dispatch ( { action : 'initialConnectSnapshots' , payload : [ ] } ) ;
40
45
useStoreContext . mockClear ( ) ;
41
46
dispatch . mockClear ( ) ;
42
47
} ) ;
43
48
44
49
describe ( 'MainContainer rendering' , ( ) => {
45
- test ( 'With no connection, shouldn not render any containers' , ( ) => {
50
+ test ( 'With no connection, should not render any containers' , ( ) => {
51
+ expect ( wrapper . text ( ) ) . toEqual ( 'please install our npm package in your app' ) ;
46
52
expect ( wrapper . find ( HeadContainer ) . length ) . toBe ( 0 ) ;
47
53
expect ( wrapper . find ( ActionContainer ) . length ) . toBe ( 0 ) ;
48
54
expect ( wrapper . find ( StateContainer ) . length ) . toBe ( 0 ) ;
49
55
expect ( wrapper . find ( TravelContainer ) . length ) . toBe ( 0 ) ;
50
56
expect ( wrapper . find ( ButtonsContainer ) . length ) . toBe ( 0 ) ;
51
57
} ) ;
52
- test ( 'With connection established, should render All containers' , ( ) => {
58
+ test ( 'With connection established, should render all containers' , ( ) => {
53
59
expect ( wrapper . find ( HeadContainer ) . length ) . toBe ( 1 ) ;
54
60
expect ( wrapper . find ( ActionContainer ) . length ) . toBe ( 1 ) ;
55
61
expect ( wrapper . find ( StateContainer ) . length ) . toBe ( 1 ) ;
0 commit comments