aboutsummaryrefslogtreecommitdiff
path: root/test/background/reducers
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-05-01 15:51:40 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-05-01 15:51:40 +0900
commit9da2f5fd786ff7ef64eca0a86efb1c0b9a164244 (patch)
treeb888349817d0016dc1499932671bbe6cd95efdaa /test/background/reducers
parentf9889b7f2b634bfe5a540633d8952f4a6f900658 (diff)
parent89d6afecfd257ff4fc62748f771abf37ef3a2852 (diff)
Merge remote-tracking branch 'origin/master' into patch-1
Diffstat (limited to 'test/background/reducers')
-rw-r--r--test/background/reducers/find.test.js19
-rw-r--r--test/background/reducers/setting.test.js36
2 files changed, 55 insertions, 0 deletions
diff --git a/test/background/reducers/find.test.js b/test/background/reducers/find.test.js
new file mode 100644
index 0000000..707d73a
--- /dev/null
+++ b/test/background/reducers/find.test.js
@@ -0,0 +1,19 @@
+import { expect } from "chai";
+import actions from 'background/actions';
+import findReducer from 'background/reducers/find';
+
+describe("find reducer", () => {
+ it('return the initial state', () => {
+ let state = findReducer(undefined, {});
+ expect(state).to.have.deep.property('keyword', null);
+ });
+
+ it('return next state for FIND_SET_KEYWORD', () => {
+ let action = {
+ type: actions.FIND_SET_KEYWORD,
+ keyword: 'cherry',
+ };
+ let state = findReducer(undefined, action);
+ expect(state).to.have.deep.property('keyword', 'cherry')
+ });
+});
diff --git a/test/background/reducers/setting.test.js b/test/background/reducers/setting.test.js
new file mode 100644
index 0000000..8df5abe
--- /dev/null
+++ b/test/background/reducers/setting.test.js
@@ -0,0 +1,36 @@
+import { expect } from "chai";
+import actions from 'background/actions';
+import settingReducer from 'background/reducers/setting';
+
+describe("setting reducer", () => {
+ it('return the initial state', () => {
+ let state = settingReducer(undefined, {});
+ expect(state).to.have.deep.property('value', {});
+ });
+
+ it('return next state for SETTING_SET_SETTINGS', () => {
+ let action = {
+ type: actions.SETTING_SET_SETTINGS,
+ value: { key: 123 },
+ };
+ let state = settingReducer(undefined, action);
+ expect(state).to.have.deep.property('value', { key: 123 });
+ });
+
+ it('return next state for SETTING_SET_PROPERTY', () => {
+ let state = {
+ value: {
+ properties: { smoothscroll: true }
+ }
+ }
+ let action = {
+ type: actions.SETTING_SET_PROPERTY,
+ name: 'encoding',
+ value: 'utf-8',
+ };
+ state = settingReducer(state, action);
+
+ expect(state.value.properties).to.have.property('smoothscroll', true);
+ expect(state.value.properties).to.have.property('encoding', 'utf-8');
+ });
+});