Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"src/js/components/settings.js": true,
"src/js/components/footer.js": true,
"src/js/components/search-input.js": true,
"src/js/components/settings.js": true,
"src/js/stores/auth.js": true,
"src/js/stores/notifications.js": true,
"src/js/stores/search.js": true,
Expand Down Expand Up @@ -103,6 +104,16 @@
"app"
],
"author": "Emmanouil Konstantinidis",
"contributors": [
{
"name": "Emmanouil Konstantinidis",
"url": "https://githib.com/ekonstantinidis"
},
{
"name": "Jake 'Sid' Smith",
"url": "https://githib.com/JakeSidSmith"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/ekonstantinidis/gitify/issues"
Expand Down
21 changes: 21 additions & 0 deletions src/js/__tests__/__mocks__/react-toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @jsx React.DOM
*/

var React = require('react');

module.exports = React.createClass({
displayName: 'ToggleMock',
getInitialState: function () {
return null;
},
defaultChecked: function () {

},
onChange: function () {
return;
},
render: function () {
return (<div>{ this.props.children }</div>);
}
});
59 changes: 59 additions & 0 deletions src/js/__tests__/components/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* global jest, describe, beforeEach, it, expect, spyOn */

jest.dontMock('reflux');
jest.dontMock('../../actions/actions.js');
jest.dontMock('../../components/settings.js');
jest.dontMock('../../stores/settings.js');

var React = require('react/addons');
var TestUtils = React.addons.TestUtils;

describe('Test for Settings Component', function () {

var Actions, SettingsStore, Settings;

beforeEach(function () {
// Mock Electron's window.require
// and remote.require('shell')
window.require = function () {
return {
sendChannel: function () {
return;
}
};
};

// Mock localStorage
window.localStorage = {
item: false,
getItem: function () {
return this.item;
}
};

Actions = require('../../actions/actions.js');
SettingsStore = require('../../stores/settings.js');
Settings = require('../../components/settings.js');
});

it('Should render the settings component', function () {

spyOn(Actions, 'setSetting');

var instance = TestUtils.renderIntoDocument(<Settings />);

expect(instance.state.participating).toBeFalsy();
expect(instance.toggleParticipating).toBeDefined();
expect(instance.appQuit).toBeDefined();

instance.toggleParticipating({
target: {
checked: true
}
});
expect(Actions.setSetting).toHaveBeenCalledWith('participating', true);

instance.appQuit();
});

});