Skip to content

Commit f9f1a2a

Browse files
committed
changed main container tests
1 parent 082a843 commit f9f1a2a

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

src/app/__tests__/MainContainer.test.js

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint-disable react/jsx-filename-extension */
22

3-
import { mount, configure } from 'enzyme';
3+
import { shallow, configure } from 'enzyme';
44
import React from 'react';
5-
import { act } from 'react-dom/test-utils';
65
import Adapter from 'enzyme-adapter-react-16';
76
import MainContainer from '../containers/MainContainer';
87
import { useStoreContext } from '../store';
@@ -18,15 +17,8 @@ const chrome = require('sinon-chrome');
1817
configure({ adapter: new Adapter() });
1918

2019
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,
3022
};
3123

3224
const dispatch = jest.fn();
@@ -49,29 +41,32 @@ const port = {
4941
chrome.runtime.connect.returns(port);
5042

5143
beforeEach(() => {
52-
wrapper = mount(<MainContainer />);
44+
wrapper = shallow(<MainContainer />);
5345
useStoreContext.mockClear();
5446
dispatch.mockClear();
5547
});
5648

5749
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+
);
6054
expect(wrapper.find(HeadContainer).length).toBe(0);
6155
expect(wrapper.find(ActionContainer).length).toBe(0);
6256
expect(wrapper.find(StateContainer).length).toBe(0);
6357
expect(wrapper.find(TravelContainer).length).toBe(0);
6458
expect(wrapper.find(ButtonsContainer).length).toBe(0);
6559
});
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 />);
7570
expect(wrapper.find(HeadContainer).length).toBe(1);
7671
expect(wrapper.find(ActionContainer).length).toBe(1);
7772
expect(wrapper.find(StateContainer).length).toBe(1);

src/app/containers/MainContainer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useEffect } from 'react';
22
import HeadContainer from './HeadContainer';
33
import ActionContainer from './ActionContainer';
44
import StateContainer from './StateContainer';

0 commit comments

Comments
 (0)