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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

93 lines
2.7 KiB

import { expect } from 'chai'
import Key from '../../../src/shared/settings/Key';
7 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
});
it('returns for Ctrl+Esc', () => {
5 years ago
let key = Key.fromMapKey('<C-Space>');
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;
});
7 years ago
});
describe('equals', () => {
5 years ago
expect(new Key({
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;
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
});
});