提交 8500a85f 编写于 作者: B Benjamin Pasero

keys - add tests for command args

上级 88971e3c
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册