aboutsummaryrefslogtreecommitdiff
path: root/test/settings/reducers/setting.test.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-07-08 21:20:49 +0900
committerGitHub <noreply@github.com>2018-07-08 21:20:49 +0900
commit37840c2abb02948d36cdcfaab9063f3ea67fdb6b (patch)
tree2662c396dea1761f57ed508616d2c76389aba5f9 /test/settings/reducers/setting.test.js
parent9f64b19bef06328999a5ed602ba89867402b9d5c (diff)
parent43beccfe0f323e2363fe97bdb6bc0d71558fda47 (diff)
Merge pull request #429 from ueokande/use-official-redux
Use official redux
Diffstat (limited to 'test/settings/reducers/setting.test.js')
-rw-r--r--test/settings/reducers/setting.test.js42
1 files changed, 38 insertions, 4 deletions
diff --git a/test/settings/reducers/setting.test.js b/test/settings/reducers/setting.test.js
index b9579cf..d800394 100644
--- a/test/settings/reducers/setting.test.js
+++ b/test/settings/reducers/setting.test.js
@@ -1,21 +1,55 @@
import actions from 'settings/actions';
import settingReducer from 'settings/reducers/setting';
-describe("setting reducer", () => {
+describe("settings setting reducer", () => {
it('return the initial state', () => {
let state = settingReducer(undefined, {});
expect(state).to.have.deep.property('json', '');
- expect(state).to.have.deep.property('value', {});
+ expect(state).to.have.deep.property('form', null);
+ expect(state).to.have.deep.property('error', '');
});
it('return next state for SETTING_SET_SETTINGS', () => {
let action = {
type: actions.SETTING_SET_SETTINGS,
+ source: 'json',
json: '{ "key": "value" }',
- value: { key: 123 },
+ form: {},
};
let state = settingReducer(undefined, action);
+ expect(state).to.have.deep.property('source', 'json');
expect(state).to.have.deep.property('json', '{ "key": "value" }');
- expect(state).to.have.deep.property('value', { key: 123 });
+ expect(state).to.have.deep.property('form', {});
+ });
+
+ it('return next state for SETTING_SHOW_ERROR', () => {
+ let action = {
+ type: actions.SETTING_SHOW_ERROR,
+ text: 'bad value',
+ json: '{}',
+ };
+ let state = settingReducer(undefined, action);
+ expect(state).to.have.deep.property('error', 'bad value');
+ expect(state).to.have.deep.property('json', '{}');
+ });
+
+ it('return next state for SETTING_SWITCH_TO_FORM', () => {
+ let action = {
+ type: actions.SETTING_SWITCH_TO_FORM,
+ form: {},
+ };
+ let state = settingReducer(undefined, action);
+ expect(state).to.have.deep.property('form', {});
+ expect(state).to.have.deep.property('source', 'form');
+ });
+
+ it('return next state for SETTING_SWITCH_TO_JSON', () => {
+ let action = {
+ type: actions.SETTING_SWITCH_TO_JSON,
+ json: '{}',
+ };
+ let state = settingReducer(undefined, action);
+ expect(state).to.have.deep.property('json', '{}');
+ expect(state).to.have.deep.property('source', 'json');
});
});