A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.7 KiB
93 lines
2.7 KiB
6 years ago
|
import { expect } from 'chai'
|
||
5 years ago
|
import Key from '../../../src/shared/settings/Key';
|
||
7 years ago
|
|
||
6 years ago
|
describe("Key", () => {
|
||
7 years ago
|
describe('fromMapKey', () => {
|
||
|
it('return for X', () => {
|
||
5 years ago
|
let key = Key.fromMapKey('x');
|
||
7 years ago
|
expect(key.key).to.equal('x');
|
||
5 years ago
|
expect(key.shift).to.be.false;
|
||
|
expect(key.ctrl).to.be.false;
|
||
|
expect(key.alt).to.be.false;
|
||
|
expect(key.meta).to.be.false;
|
||
7 years ago
|
});
|
||
|
|
||
|
it('return for Shift+X', () => {
|
||
5 years ago
|
let key = Key.fromMapKey('X');
|
||
7 years ago
|
expect(key.key).to.equal('X');
|
||
5 years ago
|
expect(key.shift).to.be.true;
|
||
|
expect(key.ctrl).to.be.false;
|
||
|
expect(key.alt).to.be.false;
|
||
|
expect(key.meta).to.be.false;
|
||
7 years ago
|
});
|
||
|
|
||
|
it('return for Ctrl+X', () => {
|
||
5 years ago
|
let key = Key.fromMapKey('<C-X>');
|
||
7 years ago
|
expect(key.key).to.equal('x');
|
||
5 years ago
|
expect(key.shift).to.be.false;
|
||
|
expect(key.ctrl).to.be.true;
|
||
|
expect(key.alt).to.be.false;
|
||
|
expect(key.meta).to.be.false;
|
||
7 years ago
|
});
|
||
|
|
||
|
it('returns for Ctrl+Meta+X', () => {
|
||
5 years ago
|
let key = Key.fromMapKey('<C-M-X>');
|
||
7 years ago
|
expect(key.key).to.equal('x');
|
||
5 years ago
|
expect(key.shift).to.be.false;
|
||
|
expect(key.ctrl).to.be.true;
|
||
|
expect(key.alt).to.be.false;
|
||
|
expect(key.meta).to.be.true;
|
||
7 years ago
|
});
|
||
|
|
||
|
it('returns for Ctrl+Shift+x', () => {
|
||
5 years ago
|
let key = Key.fromMapKey('<C-S-x>');
|
||
7 years ago
|
expect(key.key).to.equal('X');
|
||
5 years ago
|
expect(key.shift).to.be.true;
|
||
|
expect(key.ctrl).to.be.true;
|
||
|
expect(key.alt).to.be.false;
|
||
|
expect(key.meta).to.be.false;
|
||
7 years ago
|
});
|
||
|
|
||
|
it('returns for Shift+Esc', () => {
|
||
5 years ago
|
let key = Key.fromMapKey('<S-Esc>');
|
||
7 years ago
|
expect(key.key).to.equal('Esc');
|
||
5 years ago
|
expect(key.shift).to.be.true;
|
||
|
expect(key.ctrl).to.be.false;
|
||
|
expect(key.alt).to.be.false;
|
||
|
expect(key.meta).to.be.false;
|
||
7 years ago
|
});
|
||
|
|
||
|
it('returns for Ctrl+Esc', () => {
|
||
5 years ago
|
let key = Key.fromMapKey('<C-Esc>');
|
||
7 years ago
|
expect(key.key).to.equal('Esc');
|
||
5 years ago
|
expect(key.shift).to.be.false;
|
||
|
expect(key.ctrl).to.be.true;
|
||
|
expect(key.alt).to.be.false;
|
||
|
expect(key.meta).to.be.false;
|
||
7 years ago
|
});
|
||
6 years ago
|
|
||
|
it('returns for Ctrl+Esc', () => {
|
||
5 years ago
|
let key = Key.fromMapKey('<C-Space>');
|
||
6 years ago
|
expect(key.key).to.equal('Space');
|
||
5 years ago
|
expect(key.shift).to.be.false;
|
||
|
expect(key.ctrl).to.be.true;
|
||
|
expect(key.alt).to.be.false;
|
||
|
expect(key.meta).to.be.false;
|
||
6 years ago
|
});
|
||
7 years ago
|
});
|
||
|
|
||
|
describe('equals', () => {
|
||
5 years ago
|
expect(new Key({
|
||
5 years ago
|
key: 'x', shift: false, ctrl: true, alt: false, meta: false,
|
||
5 years ago
|
}).equals(new Key({
|
||
|
key: 'x', shift: false, ctrl: true, alt: false, meta: false,
|
||
|
}))).to.be.true;
|
||
6 years ago
|
|
||
5 years ago
|
expect(new Key({
|
||
|
key: 'x', shift: false, ctrl: false, alt: false, meta: false,
|
||
|
}).equals(new Key({
|
||
|
key: 'X', shift: true, ctrl: false, alt: false, meta: false,
|
||
|
}))).to.be.false;
|
||
7 years ago
|
});
|
||
|
});
|