aboutsummaryrefslogtreecommitdiff
path: root/test/background
diff options
context:
space:
mode:
Diffstat (limited to 'test/background')
-rw-r--r--test/background/actions/find.test.js12
-rw-r--r--test/background/actions/tab.test.js13
-rw-r--r--test/background/reducers/find.test.js18
-rw-r--r--test/background/reducers/setting.test.js2
-rw-r--r--test/background/reducers/tab.test.js22
5 files changed, 65 insertions, 2 deletions
diff --git a/test/background/actions/find.test.js b/test/background/actions/find.test.js
new file mode 100644
index 0000000..6b0b846
--- /dev/null
+++ b/test/background/actions/find.test.js
@@ -0,0 +1,12 @@
+import actions from 'background/actions';
+import * as findActions from 'background/actions/find';
+
+describe("find actions", () => {
+ describe("setKeyword", () => {
+ it('create FIND_SET_KEYWORD action', () => {
+ let action = findActions.setKeyword('banana');
+ expect(action.type).to.equal(actions.FIND_SET_KEYWORD);
+ expect(action.keyword).to.equal('banana');
+ });
+ });
+});
diff --git a/test/background/actions/tab.test.js b/test/background/actions/tab.test.js
new file mode 100644
index 0000000..ab57374
--- /dev/null
+++ b/test/background/actions/tab.test.js
@@ -0,0 +1,13 @@
+import actions from 'background/actions';
+import * as tabActions from 'background/actions/tab';
+
+describe("tab actions", () => {
+ describe("selected", () => {
+ it('create TAB_SELECTED action', () => {
+ let action = tabActions.selected(123);
+ expect(action.type).to.equal(actions.TAB_SELECTED);
+ expect(action.tabId).to.equal(123);
+ });
+ });
+});
+
diff --git a/test/background/reducers/find.test.js b/test/background/reducers/find.test.js
new file mode 100644
index 0000000..c366223
--- /dev/null
+++ b/test/background/reducers/find.test.js
@@ -0,0 +1,18 @@
+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
index 2ef98cb..24d02ea 100644
--- a/test/background/reducers/setting.test.js
+++ b/test/background/reducers/setting.test.js
@@ -1,4 +1,3 @@
-import { expect } from "chai";
import actions from 'background/actions';
import settingReducer from 'background/reducers/setting';
@@ -30,7 +29,6 @@ describe("setting reducer", () => {
};
state = settingReducer(state, action);
- console.log(state);
expect(state.value.properties).to.have.property('smoothscroll', true);
expect(state.value.properties).to.have.property('encoding', 'utf-8');
});
diff --git a/test/background/reducers/tab.test.js b/test/background/reducers/tab.test.js
new file mode 100644
index 0000000..09fa8a7
--- /dev/null
+++ b/test/background/reducers/tab.test.js
@@ -0,0 +1,22 @@
+import actions from 'background/actions';
+import tabReducer from 'background/reducers/tab';
+
+describe("tab reducer", () => {
+ it('return the initial state', () => {
+ let state = tabReducer(undefined, {});
+ expect(state.previousSelected).to.equal(-1);
+ expect(state.currentSelected).to.equal(-1);
+ });
+
+ it('return next state for TAB_SELECTED', () => {
+ let state = undefined;
+
+ state = tabReducer(state, { type: actions.TAB_SELECTED, tabId: 123 });
+ expect(state.previousSelected).to.equal(-1);
+ expect(state.currentSelected).to.equal(123);
+
+ state = tabReducer(state, { type: actions.TAB_SELECTED, tabId: 456 });
+ expect(state.previousSelected).to.equal(123);
+ expect(state.currentSelected).to.equal(456);
+ });
+});