Declare setting types
This commit is contained in:
parent
d01db82c0d
commit
a0882bbceb
48 changed files with 1618 additions and 903 deletions
|
@ -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' });
|
||||
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',
|
||||
},
|
||||
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.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' },
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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' }},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
Reference in a new issue