Skip to content

Commit 7475f3e

Browse files
Merge pull request #55 from ekonstantinidis/test-settings-component
Test the settings component
2 parents 2d3d002 + ae17a55 commit 7475f3e

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"src/js/components/settings.js": true,
7373
"src/js/components/footer.js": true,
7474
"src/js/components/search-input.js": true,
75+
"src/js/components/settings.js": true,
7576
"src/js/stores/auth.js": true,
7677
"src/js/stores/notifications.js": true,
7778
"src/js/stores/search.js": true,
@@ -103,6 +104,16 @@
103104
"app"
104105
],
105106
"author": "Emmanouil Konstantinidis",
107+
"contributors": [
108+
{
109+
"name": "Emmanouil Konstantinidis",
110+
"url": "https://githib.com/ekonstantinidis"
111+
},
112+
{
113+
"name": "Jake 'Sid' Smith",
114+
"url": "https://githib.com/JakeSidSmith"
115+
}
116+
],
106117
"license": "MIT",
107118
"bugs": {
108119
"url": "https://github.com/ekonstantinidis/gitify/issues"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @jsx React.DOM
3+
*/
4+
5+
var React = require('react');
6+
7+
module.exports = React.createClass({
8+
displayName: 'ToggleMock',
9+
getInitialState: function () {
10+
return null;
11+
},
12+
defaultChecked: function () {
13+
14+
},
15+
onChange: function () {
16+
return;
17+
},
18+
render: function () {
19+
return (<div>{ this.props.children }</div>);
20+
}
21+
});
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* global jest, describe, beforeEach, it, expect, spyOn */
2+
3+
jest.dontMock('reflux');
4+
jest.dontMock('../../actions/actions.js');
5+
jest.dontMock('../../components/settings.js');
6+
jest.dontMock('../../stores/settings.js');
7+
8+
var React = require('react/addons');
9+
var TestUtils = React.addons.TestUtils;
10+
11+
describe('Test for Settings Component', function () {
12+
13+
var Actions, SettingsStore, Settings;
14+
15+
beforeEach(function () {
16+
// Mock Electron's window.require
17+
// and remote.require('shell')
18+
window.require = function () {
19+
return {
20+
sendChannel: function () {
21+
return;
22+
}
23+
};
24+
};
25+
26+
// Mock localStorage
27+
window.localStorage = {
28+
item: false,
29+
getItem: function () {
30+
return this.item;
31+
}
32+
};
33+
34+
Actions = require('../../actions/actions.js');
35+
SettingsStore = require('../../stores/settings.js');
36+
Settings = require('../../components/settings.js');
37+
});
38+
39+
it('Should render the settings component', function () {
40+
41+
spyOn(Actions, 'setSetting');
42+
43+
var instance = TestUtils.renderIntoDocument(<Settings />);
44+
45+
expect(instance.state.participating).toBeFalsy();
46+
expect(instance.toggleParticipating).toBeDefined();
47+
expect(instance.appQuit).toBeDefined();
48+
49+
instance.toggleParticipating({
50+
target: {
51+
checked: true
52+
}
53+
});
54+
expect(Actions.setSetting).toHaveBeenCalledWith('participating', true);
55+
56+
instance.appQuit();
57+
});
58+
59+
});

0 commit comments

Comments
 (0)