Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for long user configured chords. #2736

Merged
merged 12 commits into from
Jul 24, 2018
4 changes: 2 additions & 2 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ export class ModeHandler implements vscode.Disposable {
case KeypressState.NoPossibleMatch:
if (!this._remappers.isPotentialRemap) {
vimState.recordedState = new RecordedState();
return vimState;
}
break;

return vimState;
case KeypressState.WaitingOnKeys:
return vimState;
}
Expand Down
62 changes: 38 additions & 24 deletions test/configuration/configuration.test.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,57 @@
import * as assert from 'assert';

import * as srcConfiguration from '../../src/configuration/configuration';
import { Globals } from '../../src/globals';
import * as testConfiguration from '../testConfiguration';
import { reloadConfiguration } from '../testUtils';
import { cleanUpWorkspace, setupWorkspace } from './../testUtils';
import { getTestingFunctions } from '../testSimplifier';
import { ModeName } from '../../src/mode/mode';

suite('Configuration', () => {
suiteSetup(() => {
let configuration = new testConfiguration.Configuration();
configuration.leader = '<space>';
configuration.normalModeKeyBindingsNonRecursive = [
{
before: ['leader', 'o'],
after: ['o', 'eSc', 'k'],
},
];

configuration.whichwrap = 'h,l';

Globals.mockConfiguration = configuration;
reloadConfiguration();
const { newTest } = getTestingFunctions();
let configuration = new testConfiguration.Configuration();
configuration.leader = '<space>';
configuration.normalModeKeyBindingsNonRecursive = [
{
before: ['leader', 'o'],
after: ['o', 'eSc', 'k'],
},
{
before: ['<leader>', 'f', 'e', 's'],
after: ['v'],
},
];
configuration.whichwrap = 'h,l';

setup(async () => {
await setupWorkspace(configuration);
});

teardown(cleanUpWorkspace);

test('remappings are normalized', async () => {
let configuration = srcConfiguration.configuration;
let keybindings = configuration.normalModeKeyBindingsNonRecursive;
const normalizedKeybinds = srcConfiguration.configuration.normalModeKeyBindingsNonRecursive;
const testingKeybinds = configuration.normalModeKeyBindingsNonRecursive;

assert.equal(normalizedKeybinds.length, testingKeybinds.length);
assert.deepEqual(normalizedKeybinds[0].before, [' ', 'o']);
assert.deepEqual(normalizedKeybinds[0].after, ['o', '<Esc>', 'k']);
});

assert.equal(keybindings.length, 1);
assert.deepEqual(keybindings[0].before, [' ', 'o']);
assert.deepEqual(keybindings[0].after, ['o', '<Esc>', 'k']);
newTest({
title: 'Can handle long key chords',
start: ['|'],
keysPressed: ' fes',
end: ['|'],
endMode: ModeName.Visual,
});

test('whichwrap is parsed into wrapKeys', async () => {
let configuration = srcConfiguration.configuration;
let wrapKeys = srcConfiguration.configuration.wrapKeys;

const h = 'h';
const j = 'j';

assert.equal(configuration.wrapKeys[h], true);
assert.equal(configuration.wrapKeys[j], undefined);
assert.equal(wrapKeys[h], true);
assert.equal(wrapKeys[j], undefined);
});
});