Vim/test/keyboard.test.ts
Jason Poon 3a37d15504 Refactor CommandKeyMap
* follow similar pattern to keyboardLayout
* all user configurations accessible through configuration class
* simplified the custom keyboard layout class
2016-05-20 23:32:42 +03:00

43 lines
1.2 KiB
TypeScript

"use strict";
// The module 'assert' provides assertion methods from node
import * as assert from 'assert';
import {KeyboardLayout, IKeyMapper} from '../src/configuration/keyboard';
suite("KeyboardLayout", () => {
test("ctor", () => {
const layout = new KeyboardLayout();
assert.equal(layout.name, "en-US (QWERTY)");
});
test("lets keys through if using default layout", () => {
const layout = new KeyboardLayout();
assert.equal(layout.translate('>'), '>');
assert.equal(layout.translate(':'), ':');
assert.equal(layout.translate('.'), '.');
});
test("can use custom mapper", () => {
class FakeMapper implements IKeyMapper {
get name() : string {
return "fake mapper";
}
get(key : string) : string {
return "fake key";
}
}
const layout = new KeyboardLayout(new FakeMapper());
assert.equal(layout.name, "fake mapper");
assert.equal(layout.translate('>'), 'fake key');
assert.equal(layout.translate(':'), 'fake key');
assert.equal(layout.translate('.'), 'fake key');
});
});
suite("KeyMapperEsEsQwerty", () => {
// TODO: cannot set settings from api?
});