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.
92 lines
2.7 KiB
92 lines
2.7 KiB
import { expect } from 'chai' |
|
import Key from '../../../src/shared/settings/Key'; |
|
|
|
describe("Key", () => { |
|
describe('fromMapKey', () => { |
|
it('return for X', () => { |
|
let key = Key.fromMapKey('x'); |
|
expect(key.key).to.equal('x'); |
|
expect(key.shift).to.be.false; |
|
expect(key.ctrl).to.be.false; |
|
expect(key.alt).to.be.false; |
|
expect(key.meta).to.be.false; |
|
}); |
|
|
|
it('return for Shift+X', () => { |
|
let key = Key.fromMapKey('X'); |
|
expect(key.key).to.equal('X'); |
|
expect(key.shift).to.be.true; |
|
expect(key.ctrl).to.be.false; |
|
expect(key.alt).to.be.false; |
|
expect(key.meta).to.be.false; |
|
}); |
|
|
|
it('return for Ctrl+X', () => { |
|
let key = Key.fromMapKey('<C-X>'); |
|
expect(key.key).to.equal('x'); |
|
expect(key.shift).to.be.false; |
|
expect(key.ctrl).to.be.true; |
|
expect(key.alt).to.be.false; |
|
expect(key.meta).to.be.false; |
|
}); |
|
|
|
it('returns for Ctrl+Meta+X', () => { |
|
let key = Key.fromMapKey('<C-M-X>'); |
|
expect(key.key).to.equal('x'); |
|
expect(key.shift).to.be.false; |
|
expect(key.ctrl).to.be.true; |
|
expect(key.alt).to.be.false; |
|
expect(key.meta).to.be.true; |
|
}); |
|
|
|
it('returns for Ctrl+Shift+x', () => { |
|
let key = Key.fromMapKey('<C-S-x>'); |
|
expect(key.key).to.equal('X'); |
|
expect(key.shift).to.be.true; |
|
expect(key.ctrl).to.be.true; |
|
expect(key.alt).to.be.false; |
|
expect(key.meta).to.be.false; |
|
}); |
|
|
|
it('returns for Shift+Esc', () => { |
|
let key = Key.fromMapKey('<S-Esc>'); |
|
expect(key.key).to.equal('Esc'); |
|
expect(key.shift).to.be.true; |
|
expect(key.ctrl).to.be.false; |
|
expect(key.alt).to.be.false; |
|
expect(key.meta).to.be.false; |
|
}); |
|
|
|
it('returns for Ctrl+Esc', () => { |
|
let key = Key.fromMapKey('<C-Esc>'); |
|
expect(key.key).to.equal('Esc'); |
|
expect(key.shift).to.be.false; |
|
expect(key.ctrl).to.be.true; |
|
expect(key.alt).to.be.false; |
|
expect(key.meta).to.be.false; |
|
}); |
|
|
|
it('returns for Ctrl+Esc', () => { |
|
let key = Key.fromMapKey('<C-Space>'); |
|
expect(key.key).to.equal('Space'); |
|
expect(key.shift).to.be.false; |
|
expect(key.ctrl).to.be.true; |
|
expect(key.alt).to.be.false; |
|
expect(key.meta).to.be.false; |
|
}); |
|
}); |
|
|
|
describe('equals', () => { |
|
expect(new Key({ |
|
key: 'x', shift: false, ctrl: true, alt: false, meta: false, |
|
}).equals(new Key({ |
|
key: 'x', shift: false, ctrl: true, alt: false, meta: false, |
|
}))).to.be.true; |
|
|
|
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; |
|
}); |
|
});
|
|
|