keys - add tests for command args

This commit is contained in:
Benjamin Pasero 2016-11-02 18:37:51 +01:00
parent 88971e3cca
commit 8500a85f6c
2 changed files with 25 additions and 2 deletions

View file

@ -136,4 +136,12 @@ suite('Keybinding IO', () => {
let normalizedKeybindingItem = NormalizedKeybindingItem.fromKeybindingItem(keybindingItem, false);
assert.equal(normalizedKeybindingItem.keybinding, 0);
});
test('test commands args', () => {
let strJSON = `[{ "key": "ctrl+k ctrl+f", "command": "firstcommand", "when": [], "args": { "text": "theText" } }]`;
let userKeybinding = <IUserFriendlyKeybinding>JSON.parse(strJSON)[0];
let keybindingItem = IOSupport.readKeybindingItem(userKeybinding, 0);
let normalizedKeybindingItem = NormalizedKeybindingItem.fromKeybindingItem(keybindingItem, false);
assert.equal(normalizedKeybindingItem.commandArgs.text, 'theText');
});
});

View file

@ -31,6 +31,23 @@ suite('Keybinding Service', () => {
assert.equal(resolver.resolve({ bar: 'bz' }, 0, keybinding), null);
});
test('resolve key with arguments', function () {
let commandArgs = { text: 'no' };
let keybinding = KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z;
let contextRules = ContextKeyExpr.equals('bar', 'baz');
let keybindingItem: IKeybindingItem = {
command: 'yes',
commandArgs: commandArgs,
when: contextRules,
keybinding: keybinding,
weight1: 0,
weight2: 0
};
let resolver = new KeybindingResolver([keybindingItem], []);
assert.equal(resolver.resolve({ bar: 'baz' }, 0, keybinding).commandArgs, commandArgs);
});
test('KbAndExpression.equals', function () {
let a = ContextKeyExpr.and(
ContextKeyExpr.has('a1'),
@ -471,8 +488,6 @@ suite('Keybinding Service', () => {
let resolver = new KeybindingResolver(items, [], false);
let testKey = (commandId: string, expectedKeys: number[]) => {
// Test lookup
let lookupResult = resolver.lookupKeybinding(commandId);