mirror of
https://github.com/Microsoft/vscode
synced 2024-10-06 03:17:00 +00:00
keys - add tests for command args
This commit is contained in:
parent
88971e3cca
commit
8500a85f6c
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue