aboutsummaryrefslogtreecommitdiff
path: root/test/settings/reducers/setting.test.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-04-30 14:00:07 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-05-02 11:14:19 +0900
commitc60d0e7392fc708e961614d6b756a045de74f458 (patch)
tree0b9a5fce1879e38a92d5dbb2915779aee0ad22d6 /test/settings/reducers/setting.test.ts
parent257162e5b6b4993e1dff0d705ffa6f0d809033eb (diff)
Rename .js/.jsx to .ts/.tsx
Diffstat (limited to 'test/settings/reducers/setting.test.ts')
-rw-r--r--test/settings/reducers/setting.test.ts55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/settings/reducers/setting.test.ts b/test/settings/reducers/setting.test.ts
new file mode 100644
index 0000000..c1a1648
--- /dev/null
+++ b/test/settings/reducers/setting.test.ts
@@ -0,0 +1,55 @@
+import actions from 'settings/actions';
+import settingReducer from 'settings/reducers/setting';
+
+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('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" }',
+ 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('form', {});
+ });
+
+ it('return next state for SETTING_SHOW_ERROR', () => {
+ let action = {
+ type: actions.SETTING_SHOW_ERROR,
+ error: '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');
+ });
+});