aboutsummaryrefslogtreecommitdiff
path: root/test/content
diff options
context:
space:
mode:
Diffstat (limited to 'test/content')
-rw-r--r--test/content/actions/follow-controller.test.ts (renamed from test/content/actions/follow-controller.test.js)2
-rw-r--r--test/content/actions/input.test.ts (renamed from test/content/actions/input.test.js)2
-rw-r--r--test/content/actions/mark.test.ts (renamed from test/content/actions/mark.test.js)2
-rw-r--r--test/content/actions/setting.test.js35
-rw-r--r--test/content/actions/setting.test.ts43
-rw-r--r--test/content/components/common/follow.test.ts (renamed from test/content/components/common/follow.test.js)0
-rw-r--r--test/content/components/common/hint.test.ts (renamed from test/content/components/common/hint.test.js)0
-rw-r--r--test/content/components/common/input.test.ts (renamed from test/content/components/common/input.test.js)14
-rw-r--r--test/content/hint-key-producer.test.ts (renamed from test/content/hint-key-producer.test.js)0
-rw-r--r--test/content/navigates.test.ts (renamed from test/content/navigates.test.js)0
-rw-r--r--test/content/reducers/addon.test.ts (renamed from test/content/reducers/addon.test.js)2
-rw-r--r--test/content/reducers/find.test.ts (renamed from test/content/reducers/find.test.js)2
-rw-r--r--test/content/reducers/follow-controller.test.ts (renamed from test/content/reducers/follow-controller.test.js)2
-rw-r--r--test/content/reducers/input.test.ts (renamed from test/content/reducers/input.test.js)2
-rw-r--r--test/content/reducers/mark.test.ts (renamed from test/content/reducers/mark.test.js)2
-rw-r--r--test/content/reducers/setting.test.js17
-rw-r--r--test/content/reducers/setting.test.ts31
17 files changed, 90 insertions, 66 deletions
diff --git a/test/content/actions/follow-controller.test.js b/test/content/actions/follow-controller.test.ts
index 718a90a..a4b1710 100644
--- a/test/content/actions/follow-controller.test.js
+++ b/test/content/actions/follow-controller.test.ts
@@ -1,4 +1,4 @@
-import actions from 'content/actions';
+import * as actions from 'content/actions';
import * as followControllerActions from 'content/actions/follow-controller';
describe('follow-controller actions', () => {
diff --git a/test/content/actions/input.test.js b/test/content/actions/input.test.ts
index fe9db5f..33238a5 100644
--- a/test/content/actions/input.test.js
+++ b/test/content/actions/input.test.ts
@@ -1,4 +1,4 @@
-import actions from 'content/actions';
+import * as actions from 'content/actions';
import * as inputActions from 'content/actions/input';
describe("input actions", () => {
diff --git a/test/content/actions/mark.test.js b/test/content/actions/mark.test.ts
index adbf06b..6c6d59e 100644
--- a/test/content/actions/mark.test.js
+++ b/test/content/actions/mark.test.ts
@@ -1,4 +1,4 @@
-import actions from 'content/actions';
+import * as actions from 'content/actions';
import * as markActions from 'content/actions/mark';
describe('mark actions', () => {
diff --git a/test/content/actions/setting.test.js b/test/content/actions/setting.test.js
deleted file mode 100644
index 10f6807..0000000
--- a/test/content/actions/setting.test.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import actions from 'content/actions';
-import * as settingActions from 'content/actions/setting';
-
-describe("setting actions", () => {
- describe("set", () => {
- it('create SETTING_SET action', () => {
- let action = settingActions.set({ red: 'apple', yellow: 'banana' });
- expect(action.type).to.equal(actions.SETTING_SET);
- expect(action.value.red).to.equal('apple');
- expect(action.value.yellow).to.equal('banana');
- expect(action.value.keymaps).to.be.empty;
- });
-
- it('converts keymaps', () => {
- let action = settingActions.set({
- keymaps: {
- 'dd': 'remove current tab',
- 'z<C-A>': 'increment',
- }
- });
- let keymaps = action.value.keymaps;
- let map = new Map(keymaps);
- expect(map).to.have.deep.all.keys(
- [
- [{ key: 'Esc', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false }],
- [{ key: '[', shiftKey: false, ctrlKey: true, altKey: false, metaKey: false }],
- [{ key: 'd', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
- { key: 'd', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false }],
- [{ key: 'z', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
- { key: 'a', shiftKey: false, ctrlKey: true, altKey: false, metaKey: false }],
- ]
- );
- });
- });
-});
diff --git a/test/content/actions/setting.test.ts b/test/content/actions/setting.test.ts
new file mode 100644
index 0000000..c831433
--- /dev/null
+++ b/test/content/actions/setting.test.ts
@@ -0,0 +1,43 @@
+import * as actions from 'content/actions';
+import * as settingActions from 'content/actions/setting';
+
+describe("setting actions", () => {
+ describe("set", () => {
+ it('create SETTING_SET action', () => {
+ let action = settingActions.set({
+ keymaps: {
+ 'dd': 'remove current tab',
+ 'z<C-A>': 'increment',
+ },
+ search: {
+ default: "google",
+ engines: {
+ google: 'https://google.com/search?q={}',
+ }
+ },
+ properties: {
+ hintchars: 'abcd1234',
+ },
+ blacklist: [],
+ });
+ expect(action.type).to.equal(actions.SETTING_SET);
+ expect(action.settings.properties.hintchars).to.equal('abcd1234');
+ });
+
+ it('overrides cancel keys', () => {
+ let action = settingActions.set({
+ keymaps: {
+ "k": { "type": "scroll.vertically", "count": -1 },
+ "j": { "type": "scroll.vertically", "count": 1 },
+ }
+ });
+ let keymaps = action.settings.keymaps;
+ expect(action.settings.keymaps).to.deep.equals({
+ "k": { type: "scroll.vertically", count: -1 },
+ "j": { type: "scroll.vertically", count: 1 },
+ '<Esc>': { type: 'cancel' },
+ '<C-[>': { type: 'cancel' },
+ });
+ });
+ });
+});
diff --git a/test/content/components/common/follow.test.js b/test/content/components/common/follow.test.ts
index 90d6cf5..90d6cf5 100644
--- a/test/content/components/common/follow.test.js
+++ b/test/content/components/common/follow.test.ts
diff --git a/test/content/components/common/hint.test.js b/test/content/components/common/hint.test.ts
index 42d571f..42d571f 100644
--- a/test/content/components/common/hint.test.js
+++ b/test/content/components/common/hint.test.ts
diff --git a/test/content/components/common/input.test.js b/test/content/components/common/input.test.ts
index 2ba5507..f3a943c 100644
--- a/test/content/components/common/input.test.js
+++ b/test/content/components/common/input.test.ts
@@ -21,12 +21,14 @@ describe('InputComponent', () => {
++b;
}
});
- component.onKeyDown({ key: 'a' });
- component.onKeyDown({ key: 'b' });
- component.onKeyPress({ key: 'a' });
- component.onKeyUp({ key: 'a' });
- component.onKeyPress({ key: 'b' });
- component.onKeyUp({ key: 'b' });
+
+ let elem = document.body;
+ component.onKeyDown({ key: 'a', target: elem });
+ component.onKeyDown({ key: 'b', target: elem });
+ component.onKeyPress({ key: 'a', target: elem });
+ component.onKeyUp({ key: 'a', target: elem });
+ component.onKeyPress({ key: 'b', target: elem });
+ component.onKeyUp({ key: 'b', target: elem });
expect(a).is.equals(1);
expect(b).is.equals(1);
diff --git a/test/content/hint-key-producer.test.js b/test/content/hint-key-producer.test.ts
index dcf477d..dcf477d 100644
--- a/test/content/hint-key-producer.test.js
+++ b/test/content/hint-key-producer.test.ts
diff --git a/test/content/navigates.test.js b/test/content/navigates.test.ts
index 1d73344..1d73344 100644
--- a/test/content/navigates.test.js
+++ b/test/content/navigates.test.ts
diff --git a/test/content/reducers/addon.test.js b/test/content/reducers/addon.test.ts
index d4eb845..fb05244 100644
--- a/test/content/reducers/addon.test.js
+++ b/test/content/reducers/addon.test.ts
@@ -1,4 +1,4 @@
-import actions from 'content/actions';
+import * as actions from 'content/actions';
import addonReducer from 'content/reducers/addon';
describe("addon reducer", () => {
diff --git a/test/content/reducers/find.test.js b/test/content/reducers/find.test.ts
index a8c30d7..66a2c67 100644
--- a/test/content/reducers/find.test.js
+++ b/test/content/reducers/find.test.ts
@@ -1,4 +1,4 @@
-import actions from 'content/actions';
+import * as actions from 'content/actions';
import findReducer from 'content/reducers/find';
describe("find reducer", () => {
diff --git a/test/content/reducers/follow-controller.test.js b/test/content/reducers/follow-controller.test.ts
index 8a4c2d4..39f326c 100644
--- a/test/content/reducers/follow-controller.test.js
+++ b/test/content/reducers/follow-controller.test.ts
@@ -1,4 +1,4 @@
-import actions from 'content/actions';
+import * as actions from 'content/actions';
import followControllerReducer from 'content/reducers/follow-controller';
describe('follow-controller reducer', () => {
diff --git a/test/content/reducers/input.test.js b/test/content/reducers/input.test.ts
index 0011943..f892201 100644
--- a/test/content/reducers/input.test.js
+++ b/test/content/reducers/input.test.ts
@@ -1,4 +1,4 @@
-import actions from 'content/actions';
+import * as actions from 'content/actions';
import inputReducer from 'content/reducers/input';
describe("input reducer", () => {
diff --git a/test/content/reducers/mark.test.js b/test/content/reducers/mark.test.ts
index 76efbf7..1a51c3e 100644
--- a/test/content/reducers/mark.test.js
+++ b/test/content/reducers/mark.test.ts
@@ -1,4 +1,4 @@
-import actions from 'content/actions';
+import * as actions from 'content/actions';
import reducer from 'content/reducers/mark';
describe("mark reducer", () => {
diff --git a/test/content/reducers/setting.test.js b/test/content/reducers/setting.test.js
deleted file mode 100644
index 4e4c095..0000000
--- a/test/content/reducers/setting.test.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import actions from 'content/actions';
-import settingReducer from 'content/reducers/setting';
-
-describe("content setting reducer", () => {
- it('return the initial state', () => {
- let state = settingReducer(undefined, {});
- expect(state.keymaps).to.be.empty;
- });
-
- it('return next state for SETTING_SET', () => {
- let newSettings = { red: 'apple', yellow: 'banana' };
- let action = { type: actions.SETTING_SET, value: newSettings };
- let state = settingReducer(undefined, action);
- expect(state).to.deep.equal(newSettings);
- expect(state).not.to.equal(newSettings); // assert deep copy
- });
-});
diff --git a/test/content/reducers/setting.test.ts b/test/content/reducers/setting.test.ts
new file mode 100644
index 0000000..9b332aa
--- /dev/null
+++ b/test/content/reducers/setting.test.ts
@@ -0,0 +1,31 @@
+import * as actions from 'content/actions';
+import settingReducer from 'content/reducers/setting';
+
+describe("content setting reducer", () => {
+ it('return the initial state', () => {
+ let state = settingReducer(undefined, {});
+ expect(state.keymaps).to.be.empty;
+ });
+
+ it('return next state for SETTING_SET', () => {
+ let newSettings = { red: 'apple', yellow: 'banana' };
+ let action = {
+ type: actions.SETTING_SET,
+ settings: {
+ keymaps: {
+ "zz": { type: "zoom.neutral" },
+ "<S-Esc>": { "type": "addon.toggle.enabled" }
+ },
+ "blacklist": []
+ }
+ }
+ let state = settingReducer(undefined, action);
+ expect(state.keymaps).to.have.deep.all.members([
+ { key: [{ key: 'z', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false },
+ { key: 'z', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false }],
+ op: { type: 'zoom.neutral' }},
+ { key: [{ key: 'Esc', shiftKey: true, ctrlKey: false, altKey: false, metaKey: false }],
+ op: { type: 'addon.toggle.enabled' }},
+ ]);
+ });
+});