diff options
Diffstat (limited to 'test/content')
-rw-r--r-- | test/content/actions/setting.test.ts | 46 | ||||
-rw-r--r-- | test/content/reducers/setting.test.ts | 21 |
2 files changed, 45 insertions, 22 deletions
diff --git a/test/content/actions/setting.test.ts b/test/content/actions/setting.test.ts index 0721d5d..c831433 100644 --- a/test/content/actions/setting.test.ts +++ b/test/content/actions/setting.test.ts @@ -4,32 +4,40 @@ 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' }); + 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.value.red).to.equal('apple'); - expect(action.value.yellow).to.equal('banana'); - expect(action.value.keymaps).to.be.empty; + expect(action.settings.properties.hintchars).to.equal('abcd1234'); }); - it('converts keymaps', () => { + it('overrides cancel keys', () => { let action = settingActions.set({ keymaps: { - 'dd': 'remove current tab', - 'z<C-A>': 'increment', + "k": { "type": "scroll.vertically", "count": -1 }, + "j": { "type": "scroll.vertically", "count": 1 }, } }); - 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 }], - ] - ); + 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/reducers/setting.test.ts b/test/content/reducers/setting.test.ts index 226fc58..fe23006 100644 --- a/test/content/reducers/setting.test.ts +++ b/test/content/reducers/setting.test.ts @@ -9,9 +9,24 @@ describe("content setting reducer", () => { it('return next state for SETTING_SET', () => { let newSettings = { red: 'apple', yellow: 'banana' }; - let action = { type: actions.SETTING_SET, value: newSettings }; + 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).to.deep.equal(newSettings); - expect(state).not.to.equal(newSettings); // assert deep copy + console.log(JSON.stringify(state.keymaps)); + 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' }}, + ]); }); }); |