Skip to content

Commit 94467ba

Browse files
author
Emmanouil Konstantinidis
committed
Test settings store
1 parent 76d8c52 commit 94467ba

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*global jest, describe, it, expect, spyOn, beforeEach */
2+
3+
'use strict';
4+
5+
jest.dontMock('reflux');
6+
jest.dontMock('../../stores/settings.js');
7+
jest.dontMock('../../actions/actions.js');
8+
9+
describe('Tests for SettingsStore', function () {
10+
11+
var SettingsStore, Actions;
12+
13+
beforeEach(function () {
14+
15+
// Mock Electron's window.require
16+
window.require = function () {
17+
return {
18+
sendChannel: function () {
19+
return;
20+
}
21+
};
22+
};
23+
24+
// Mock localStorage
25+
window.localStorage = {
26+
item: false,
27+
getItem: function () {
28+
return this.item;
29+
},
30+
setItem: function (item) {
31+
this.item = item;
32+
}
33+
};
34+
35+
Actions = require('../../actions/actions.js');
36+
SettingsStore = require('../../stores/settings.js');
37+
});
38+
39+
it('should get the settings', function () {
40+
41+
spyOn(SettingsStore, 'trigger');
42+
43+
expect(SettingsStore.getSettings().participating).toBe(false);
44+
45+
});
46+
47+
it('should set a setting', function () {
48+
49+
spyOn(SettingsStore, 'trigger');
50+
51+
SettingsStore.onSetSetting('participating', true);
52+
53+
expect(SettingsStore.getSettings().participating).toBe(true);
54+
55+
});
56+
57+
});

src/js/stores/settings.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ var SettingsStore = Reflux.createStore({
2525
},
2626

2727
onSetSetting: function (setting, value) {
28-
console.log('Setting: ' + setting + ' to: ' + value);
2928
this._settings[setting] = value;
3029
window.localStorage.setItem('settings', JSON.stringify(this._settings));
3130
this.trigger(this._settings);

0 commit comments

Comments
 (0)