From a0882bbceb7ed71d56bf8557620449fbc3f19749 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 5 May 2019 08:03:29 +0900 Subject: Declare setting types --- test/content/actions/setting.test.ts | 46 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'test/content/actions/setting.test.ts') 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': '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': '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 }, + '': { type: 'cancel' }, + '': { type: 'cancel' }, + }); }); }); }); -- cgit v1.2.3