Skip to content

Commit ebac4af

Browse files
committed
Improves test coverage.
1 parent db51285 commit ebac4af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1734
-341
lines changed

Utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {applyMiddleware, createStore} from 'redux';
33
import rootReducer from './../src/reducers';
44
import {middleware} from './../src/store';
55

6-
export const findByTestAtrr = (component, attr) => {
6+
export const findByTestAttr = (component, attr) => {
77
const wrapper = component.find(`[data-test='${attr}']`);
88
return wrapper;
99
};

src/App.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {shallow} from 'enzyme/build';
33
import App from './App';
4-
import {findByTestAtrr, testStore} from "../Utils";
4+
import {findByTestAttr, testStore} from "../Utils";
55
import {Provider} from "react-redux";
66
import toJson from 'enzyme-to-json';
77

@@ -46,7 +46,7 @@ describe('App Component', function () {
4646
});
4747

4848
it('should render without errors', function () {
49-
const component = findByTestAtrr(wrapper, 'appComponent');
49+
const component = findByTestAttr(wrapper, 'appComponent');
5050
expect(component).toHaveLength(1);
5151

5252
});

src/containers/DefaultLayout/DefaultLayout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DefaultLayout extends Component {
4141
return (
4242

4343

44-
<div className="app">
44+
<div className="app" data-test="defaultLayout">
4545
<AppHeader fixed>
4646
<Suspense fallback={this.loading()}>
4747
<DefaultHeader onLogout={e => this.signOut(e)}/>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from "react";
2+
import {shallow} from "enzyme";
3+
import toJson from "enzyme-to-json";
4+
import DefaultLayout from "./DefaultLayout";
5+
import {TEST_REDUX_PROPS} from "../../utils/testData";
6+
import {findByTestAttr, testStore} from "../../../Utils";
7+
8+
const setUp = (initialState = {}, props = {}) => {
9+
const store = testStore(initialState);
10+
const component = shallow(<DefaultLayout {...props} store={store}/>);
11+
return component.childAt(0).dive();
12+
};
13+
14+
15+
describe('Remote Explorer', function () {
16+
17+
18+
describe('renders', function () {
19+
let wrapper;
20+
beforeEach(() => {
21+
const initialState = {
22+
...TEST_REDUX_PROPS
23+
};
24+
25+
26+
const props = {
27+
28+
history: {
29+
push: jest.fn()
30+
}
31+
32+
};
33+
wrapper = setUp(initialState, props)
34+
});
35+
36+
it('should render without crashing', function () {
37+
const component = findByTestAttr(wrapper, "defaultLayout");
38+
expect(component).toHaveLength(1);
39+
});
40+
it('should match snapshot', function () {
41+
expect(toJson(wrapper)).toMatchSnapshot()
42+
});
43+
});
44+
45+
});

0 commit comments

Comments
 (0)