aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/reducers/setting.test.js22
-rw-r--r--test/shared/validators/setting.test.js25
2 files changed, 47 insertions, 0 deletions
diff --git a/test/reducers/setting.test.js b/test/reducers/setting.test.js
new file mode 100644
index 0000000..7261be6
--- /dev/null
+++ b/test/reducers/setting.test.js
@@ -0,0 +1,22 @@
+import { expect } from "chai";
+import actions from '../../src/actions';
+import settingReducer from '../../src/reducers/setting';
+
+describe("setting reducer", () => {
+ it('return the initial state', () => {
+ let state = settingReducer(undefined, {});
+ expect(state).to.have.deep.property('settings', {});
+ });
+
+ it('return next state for SETTING_SET_SETTINGS', () => {
+ let action = {
+ type: actions.SETTING_SET_SETTINGS,
+ settings: { value1: 'hello', value2: 'world' },
+ };
+ let state = settingReducer(undefined, action);
+ expect(state).to.have.deep.property('settings', {
+ value1: 'hello',
+ value2: 'world',
+ });
+ });
+});
diff --git a/test/shared/validators/setting.test.js b/test/shared/validators/setting.test.js
new file mode 100644
index 0000000..8bf0cbe
--- /dev/null
+++ b/test/shared/validators/setting.test.js
@@ -0,0 +1,25 @@
+import { expect } from "chai";
+import { validate } from '../../../src/shared/validators/setting';
+
+describe("setting validator", () => {
+ describe("unknown top keys", () => {
+ it('throws an error for unknown settings', () => {
+ let settings = { keymaps: {}, poison: 123 };
+ let fn = validate.bind(undefined, settings)
+ expect(fn).to.throw(Error, 'poison');
+ })
+ });
+
+ describe("keymaps settings", () => {
+ it('throws an error for unknown operation', () => {
+ let settings = {
+ keymaps: {
+ a: { 'type': 'scroll.home' },
+ b: { 'type': 'poison.dressing' },
+ }
+ };
+ let fn = validate.bind(undefined, settings)
+ expect(fn).to.throw(Error, 'poison.dressing');
+ });
+ });
+});