Skip to content

Commit 970ab26

Browse files
author
Emmanouil Konstantinidis
committed
Init tests for navigation
1 parent 460955f commit 970ab26

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* global jest, describe, beforeEach, it, expect, spyOn */
2+
3+
jest.dontMock('reflux');
4+
jest.dontMock('../../actions/actions.js');
5+
jest.dontMock('../../utils/api-requests');
6+
jest.dontMock('../../components/Navigation.js');
7+
jest.dontMock('../../stores/auth.js');
8+
9+
var React = require('react/addons');
10+
var TestUtils = React.addons.TestUtils;
11+
12+
describe('Test for Navigation', function () {
13+
14+
var apiRequests, Actions, Navigation, AuthStore;
15+
16+
beforeEach(function () {
17+
// Mock Electron's window.require
18+
// and remote.require('shell')
19+
window.require = function () {
20+
return {
21+
sendChannel: function () {
22+
return;
23+
}
24+
};
25+
};
26+
27+
// Mock localStorage
28+
window.localStorage = {
29+
item: false,
30+
getItem: function () {
31+
return this.item;
32+
}
33+
};
34+
35+
apiRequests = require('../../utils/api-requests.js');
36+
Actions = require('../../actions/actions.js');
37+
AuthStore = require('../../stores/auth.js');
38+
Navigation = require('../../components/navigation.js');
39+
});
40+
41+
it('Should load the navigation component for logged out users', function () {
42+
43+
AuthStore.authStatus = function () {
44+
return false;
45+
};
46+
47+
var instance = TestUtils.renderIntoDocument(<Navigation />);
48+
expect(instance.state.loading).toBeFalsy();
49+
expect(instance.refreshNotifications).toBeDefined();
50+
expect(instance.refreshDone).toBeDefined();
51+
expect(instance.logOut).toBeDefined();
52+
expect(instance.appQuit).toBeDefined();
53+
54+
var logoutIcon = TestUtils.scryRenderedDOMComponentsWithClass(instance, 'fa-sign-out');
55+
expect(logoutIcon.length).toBe(0);
56+
57+
});
58+
59+
60+
it('Should load the navigation component for logged in users', function () {
61+
62+
AuthStore.authStatus = function () {
63+
return true;
64+
};
65+
66+
var instance = TestUtils.renderIntoDocument(<Navigation />);
67+
expect(instance.state.loading).toBeFalsy();
68+
expect(instance.refreshNotifications).toBeDefined();
69+
expect(instance.refreshDone).toBeDefined();
70+
expect(instance.logOut).toBeDefined();
71+
expect(instance.appQuit).toBeDefined();
72+
73+
});
74+
75+
});

0 commit comments

Comments
 (0)