aboutsummaryrefslogtreecommitdiff
path: root/test/settings/reducers
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-05-02 17:25:56 +0900
committerGitHub <noreply@github.com>2020-05-02 17:25:56 +0900
commit5df0537bcf65a341e79852b1b30379c73318529c (patch)
treeaee5efe52412855f620cb514a13a2c14373f27b7 /test/settings/reducers
parent685f2b7b69218b06b5bb676069e35f79c5048c9b (diff)
parent75abd90ecb8201ad845b266f96220d8adfe19b2d (diff)
Merge pull request #749 from ueokande/qa-0.28
QA 0.28
Diffstat (limited to 'test/settings/reducers')
-rw-r--r--test/settings/reducers/setting.test.ts67
1 files changed, 37 insertions, 30 deletions
diff --git a/test/settings/reducers/setting.test.ts b/test/settings/reducers/setting.test.ts
index 60df061..99c4c80 100644
--- a/test/settings/reducers/setting.test.ts
+++ b/test/settings/reducers/setting.test.ts
@@ -1,54 +1,61 @@
-import * as actions from 'settings/actions';
-import settingReducer from 'settings/reducers/setting';
+import * as actions from "../../../src/settings/actions";
+import settingReducer from "../../../src/settings/reducers/setting";
+import { expect } from "chai";
+import {
+ FormSettings,
+ JSONTextSettings,
+ SettingSource,
+} from "../../../src/shared/SettingData";
+import { DefaultSetting } from "../../../src/shared/settings/Settings";
describe("settings setting reducer", () => {
- it('return the initial state', () => {
- const state = settingReducer(undefined, {});
- expect(state).to.have.deep.property('source', 'json');
- expect(state).to.have.deep.property('error', '');
+ it("return the initial state", () => {
+ const state = settingReducer(undefined, {} as any);
+ expect(state).to.have.deep.property("source", "json");
+ expect(state).to.have.deep.property("error", "");
});
- it('return next state for SETTING_SET_SETTINGS', () => {
- const action = {
+ it("return next state for SETTING_SET_SETTINGS", () => {
+ const action: actions.SettingAction = {
type: actions.SETTING_SET_SETTINGS,
- source: 'json',
- json: '{ "key": "value" }',
- form: {},
+ source: SettingSource.JSON,
+ json: JSONTextSettings.fromText('{ "key": "value" }'),
+ form: FormSettings.fromSettings(DefaultSetting),
};
const 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', {});
+ expect(state.source).to.equal("json");
+ expect(state.json!!.toJSONText()).to.equal('{ "key": "value" }');
+ expect(state.form).to.deep.equal(action.form);
});
- it('return next state for SETTING_SHOW_ERROR', () => {
- const action = {
+ it("return next state for SETTING_SHOW_ERROR", () => {
+ const action: actions.SettingAction = {
type: actions.SETTING_SHOW_ERROR,
- error: 'bad value',
- json: '{}',
+ error: "bad value",
+ json: JSONTextSettings.fromText("{}"),
};
const state = settingReducer(undefined, action);
- expect(state).to.have.deep.property('error', 'bad value');
- expect(state).to.have.deep.property('json', '{}');
+ expect(state.error).to.equal("bad value");
+ expect(state.json!!.toJSONText()).to.equal("{}");
});
- it('return next state for SETTING_SWITCH_TO_FORM', () => {
- const action = {
+ it("return next state for SETTING_SWITCH_TO_FORM", () => {
+ const action: actions.SettingAction = {
type: actions.SETTING_SWITCH_TO_FORM,
- form: {},
+ form: FormSettings.fromSettings(DefaultSetting),
};
const state = settingReducer(undefined, action);
- expect(state).to.have.deep.property('form', {});
- expect(state).to.have.deep.property('source', 'form');
+ expect(state.form).to.deep.equal(action.form);
+ expect(state.source).to.equal("form");
});
- it('return next state for SETTING_SWITCH_TO_JSON', () => {
- const action = {
+ it("return next state for SETTING_SWITCH_TO_JSON", () => {
+ const action: actions.SettingAction = {
type: actions.SETTING_SWITCH_TO_JSON,
- json: '{}',
+ json: JSONTextSettings.fromText("{}"),
};
const state = settingReducer(undefined, action);
- expect(state).to.have.deep.property('json', '{}');
- expect(state).to.have.deep.property('source', 'json');
+ expect(state.json!!.toJSONText()).to.equal("{}");
+ expect(state.source).to.equal(SettingSource.JSON);
});
});