diff --git a/package.json b/package.json index 277ff0f3e..a7d7e74cb 100644 --- a/package.json +++ b/package.json @@ -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, @@ -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" diff --git a/src/js/__tests__/__mocks__/react-toggle.js b/src/js/__tests__/__mocks__/react-toggle.js new file mode 100644 index 000000000..f45f80de4 --- /dev/null +++ b/src/js/__tests__/__mocks__/react-toggle.js @@ -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 (
{ this.props.children }
); + } +}); diff --git a/src/js/__tests__/components/settings.js b/src/js/__tests__/components/settings.js new file mode 100644 index 000000000..b5eda9a71 --- /dev/null +++ b/src/js/__tests__/components/settings.js @@ -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(); + + 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(); + }); + +});