Skip to content

Commit 44561f5

Browse files
committed
Fix failing tests
Fix failing tests for plugin components Fix failing tests for plugin components
1 parent 6dee82d commit 44561f5

23 files changed

+732
-244
lines changed

.idea/shelf/Uncommitted_changes_before_Update_at_17_06_20__7_26_PM__Default_Changelist_.xml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.idea/shelf/Uncommitted_changes_before_rebase__Default_Changelist_.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/containers/DefaultLayout/__snapshots__/DefaultLayout.test.js.snap

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,21 @@ exports[`Remote Explorer renders should match snapshot 1`] = `
7676
"name": "Backend",
7777
"url": "/rcloneBackend",
7878
},
79+
Object {
80+
"icon": "fa fa-plug",
81+
"name": "Plugins",
82+
"url": "/pluginDashboard",
83+
},
7984
Object {
8085
"icon": "fa fa-hdd-o",
8186
"name": "Mounts",
8287
"url": "/mountDashboard",
8388
},
89+
Object {
90+
"icon": "fa fa-terminal",
91+
"name": "Terminal",
92+
"url": "/terminal",
93+
},
8494
Object {
8595
"icon": "icon-logout",
8696
"name": "Log Out",
@@ -204,6 +214,16 @@ exports[`Remote Explorer renders should match snapshot 1`] = `
204214
"name": "Rclone Backend",
205215
"path": "/rcloneBackend",
206216
},
217+
Object {
218+
"component": Object {
219+
"$$typeof": Symbol(react.lazy),
220+
"_ctor": [Function],
221+
"_result": null,
222+
"_status": -1,
223+
},
224+
"name": "Plugins",
225+
"path": "/pluginDashboard",
226+
},
207227
Object {
208228
"component": Object {
209229
"$$typeof": Symbol(react.lazy),
@@ -214,6 +234,26 @@ exports[`Remote Explorer renders should match snapshot 1`] = `
214234
"name": "Mount Dashboard",
215235
"path": "/mountDashboard",
216236
},
237+
Object {
238+
"component": Object {
239+
"$$typeof": Symbol(react.lazy),
240+
"_ctor": [Function],
241+
"_result": null,
242+
"_status": -1,
243+
},
244+
"name": "Store Dashboard",
245+
"path": "/storeDashboard",
246+
},
247+
Object {
248+
"component": Object {
249+
"$$typeof": Symbol(react.lazy),
250+
"_ctor": [Function],
251+
"_result": null,
252+
"_status": -1,
253+
},
254+
"name": "Terminal",
255+
"path": "/terminal",
256+
},
217257
]
218258
}
219259
className=""
@@ -286,10 +326,28 @@ exports[`Remote Explorer renders should match snapshot 1`] = `
286326
/>
287327
<Route
288328
key="9"
329+
name="Plugins"
330+
path="/pluginDashboard"
331+
render={[Function]}
332+
/>
333+
<Route
334+
key="10"
289335
name="Mount Dashboard"
290336
path="/mountDashboard"
291337
render={[Function]}
292338
/>
339+
<Route
340+
key="11"
341+
name="Store Dashboard"
342+
path="/storeDashboard"
343+
render={[Function]}
344+
/>
345+
<Route
346+
key="12"
347+
name="Terminal"
348+
path="/terminal"
349+
render={[Function]}
350+
/>
293351
<Redirect
294352
from="/"
295353
to="/dashboard"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from "react";
2+
import {shallow} from "enzyme";
3+
import toJson from "enzyme-to-json";
4+
import DashboardPlugin from "./DashboardPlugin";
5+
import {findByTestAttr, testStore} from "../../../../Utils";
6+
7+
8+
const setUp = (intialState = {}, props = {}) => {
9+
const store = testStore(intialState);
10+
11+
const component = shallow(<DashboardPlugin {...props} store={store}/>);
12+
return component;
13+
};
14+
15+
16+
describe('Dashboard Plugin', function () {
17+
18+
describe('renders', function () {
19+
let wrapper;
20+
beforeEach(() => {
21+
const initialState = {};
22+
23+
const props = {
24+
pluginUrl: ""
25+
};
26+
wrapper = setUp(initialState, props)
27+
});
28+
29+
it('should render without crashing', function () {
30+
const component = findByTestAttr(wrapper, "dashboardPluginComponent");
31+
expect(component).toHaveLength(1);
32+
});
33+
34+
it('should match snapshot', function () {
35+
expect(toJson(wrapper)).toMatchSnapshot()
36+
});
37+
});
38+
39+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Dashboard Plugin renders should match snapshot 1`] = `
4+
<div
5+
data-test="dashboardPluginComponent"
6+
>
7+
<p>
8+
Could not find any appropriate plugin to load
9+
</p>
10+
</div>
11+
`;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from "react";
2+
import {shallow} from "enzyme";
3+
import toJson from "enzyme-to-json";
4+
import {findByTestAttr, testStore} from "../../../../../Utils";
5+
import NoPluginAvailableModal from "./NoPluginAvailableModal";
6+
7+
8+
const setUp = (intialState = {}, props = {}) => {
9+
const store = testStore(intialState);
10+
11+
const component = shallow(<NoPluginAvailableModal {...props} store={store}/>);
12+
return component;
13+
};
14+
15+
16+
describe('No plugin available Modal', function () {
17+
describe('renders', function () {
18+
let wrapper;
19+
beforeEach(() => {
20+
const initialState = {};
21+
22+
const props = {
23+
className: "",
24+
isOpen: true,
25+
setIsOpen: jest.fn(),
26+
availablePlugins: [],
27+
processOpenPlugin: jest.fn()
28+
};
29+
wrapper = setUp(initialState, props)
30+
});
31+
32+
it('should render without crashing', function () {
33+
const component = findByTestAttr(wrapper, "noPluginAvailableModal");
34+
expect(component).toHaveLength(1);
35+
});
36+
37+
it('should have ok and cancel buttons', function () {
38+
const okButton = findByTestAttr(wrapper, "ok-button")
39+
expect(okButton).toHaveLength(1);
40+
41+
const cancelButton = findByTestAttr(wrapper, "cancel-button");
42+
expect(cancelButton).toHaveLength(1);
43+
})
44+
45+
46+
it('should match snapshot', function () {
47+
expect(toJson(wrapper)).toMatchSnapshot();
48+
});
49+
50+
});
51+
});
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`No plugin available Modal renders should match snapshot 1`] = `
4+
<div
5+
data-test="noPluginAvailableModal"
6+
>
7+
<Modal
8+
autoFocus={true}
9+
backdrop={true}
10+
backdropTransition={
11+
Object {
12+
"mountOnEnter": true,
13+
"timeout": 150,
14+
}
15+
}
16+
centered={false}
17+
className=""
18+
container="body"
19+
fade={true}
20+
isOpen={true}
21+
keyboard={true}
22+
modalTransition={
23+
Object {
24+
"timeout": 300,
25+
}
26+
}
27+
onClosed={[Function]}
28+
onOpened={[Function]}
29+
returnFocusAfterClose={true}
30+
role="dialog"
31+
scrollable={false}
32+
toggle={[Function]}
33+
unmountOnClose={true}
34+
zIndex={1050}
35+
>
36+
<ModalHeader
37+
charCode={215}
38+
closeAriaLabel="Close"
39+
tag="h5"
40+
toggle={[MockFunction]}
41+
wrapTag="div"
42+
>
43+
Couldn't find a plugin to open this file
44+
</ModalHeader>
45+
<ModalBody
46+
tag="div"
47+
>
48+
<Table
49+
className="table-striped"
50+
responsive={true}
51+
responsiveTag="div"
52+
tag="table"
53+
>
54+
<thead>
55+
<tr>
56+
<th>
57+
Name
58+
</th>
59+
<th>
60+
Author
61+
</th>
62+
<th>
63+
Description
64+
</th>
65+
<th />
66+
</tr>
67+
</thead>
68+
<tbody>
69+
<p
70+
className="p-3"
71+
>
72+
Can't find a plugin to open this file. Go to the store and install some!
73+
</p>
74+
</tbody>
75+
</Table>
76+
</ModalBody>
77+
<ModalFooter
78+
tag="div"
79+
>
80+
<Button
81+
color="primary"
82+
data-test="ok-button"
83+
tag="button"
84+
>
85+
Go to Store
86+
</Button>
87+
88+
<Button
89+
color="secondary"
90+
data-test="cancel-button"
91+
onClick={[Function]}
92+
tag="button"
93+
>
94+
Cancel
95+
</Button>
96+
</ModalFooter>
97+
</Modal>
98+
</div>
99+
`;

0 commit comments

Comments
 (0)