aboutsummaryrefslogtreecommitdiff
path: root/test/shared/settings
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-12-22 10:47:00 +0900
committerGitHub <noreply@github.com>2019-12-22 10:47:00 +0900
commitb2dcdedad729ff7087867da50e20578f9fc8fb29 (patch)
tree033ecffbd7db9b6db8000464a68d748fcae1dc3d /test/shared/settings
parent3c7230c3036e8bb2b2e9a752be9b0ef4a0a7349d (diff)
parent75f86907fc2699c0f0661d4780c38249a18f849b (diff)
Merge pull request #689 from ueokande/n-times-repeat-operations
Repeat commands n-times
Diffstat (limited to 'test/shared/settings')
-rw-r--r--test/shared/settings/Key.test.ts33
-rw-r--r--test/shared/settings/KeySequence.test.ts72
2 files changed, 23 insertions, 82 deletions
diff --git a/test/shared/settings/Key.test.ts b/test/shared/settings/Key.test.ts
index 8222d5a..91a47f8 100644
--- a/test/shared/settings/Key.test.ts
+++ b/test/shared/settings/Key.test.ts
@@ -76,17 +76,30 @@ describe("Key", () => {
});
});
+ describe('idDigit', () => {
+ it('returns true if the key is a digit', () => {
+ expect(new Key({ key: '0' }).isDigit()).to.be.true;
+ expect(new Key({ key: '9' }).isDigit()).to.be.true;
+ expect(new Key({ key: '9', shift: true }).isDigit()).to.be.true;
+
+ expect(new Key({ key: 'a' }).isDigit()).to.be.false;
+ expect(new Key({ key: '0' }).isDigit()).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;
+ it('returns true if the keys are equivalent', () => {
+ 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;
+ 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;
+ })
});
});
diff --git a/test/shared/settings/KeySequence.test.ts b/test/shared/settings/KeySequence.test.ts
deleted file mode 100644
index 361cbd1..0000000
--- a/test/shared/settings/KeySequence.test.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import KeySequence from '../../../src/shared/settings/KeySequence';
-import { expect } from 'chai'
-import Key from "../../../src/shared/settings/Key";
-
-describe("KeySequence", () => {
- describe('#push', () => {
- it('append a key to the sequence', () => {
- let seq = new KeySequence([]);
- seq.push(Key.fromMapKey('g'));
- seq.push(Key.fromMapKey('<S-U>'));
-
- expect(seq.keys[0].key).to.equal('g');
- expect(seq.keys[1].key).to.equal('U');
- expect(seq.keys[1].shift).to.be.true;
- })
- });
-
- describe('#startsWith', () => {
- it('returns true if the key sequence starts with param', () => {
- let seq = new KeySequence([
- Key.fromMapKey('g'),
- Key.fromMapKey('<S-U>'),
- ]);
-
- expect(seq.startsWith(new KeySequence([
- ]))).to.be.true;
- expect(seq.startsWith(new KeySequence([
- Key.fromMapKey('g'),
- ]))).to.be.true;
- expect(seq.startsWith(new KeySequence([
- Key.fromMapKey('g'), Key.fromMapKey('<S-U>'),
- ]))).to.be.true;
- expect(seq.startsWith(new KeySequence([
- Key.fromMapKey('g'), Key.fromMapKey('<S-U>'), Key.fromMapKey('x'),
- ]))).to.be.false;
- expect(seq.startsWith(new KeySequence([
- Key.fromMapKey('h'),
- ]))).to.be.false;
- });
-
- it('returns true if the empty sequence starts with an empty sequence', () => {
- let seq = new KeySequence([]);
-
- expect(seq.startsWith(new KeySequence([]))).to.be.true;
- expect(seq.startsWith(new KeySequence([
- Key.fromMapKey('h'),
- ]))).to.be.false;
- })
- });
-
- describe('#fromMapKeys', () => {
- it('returns mapped keys for Shift+Esc', () => {
- let keys = KeySequence.fromMapKeys('<S-Esc>').keys;
- expect(keys).to.have.lengthOf(1);
- expect(keys[0].key).to.equal('Esc');
- expect(keys[0].shift).to.be.true;
- });
-
- it('returns mapped keys for a<C-B><A-C>d<M-e>', () => {
- let keys = KeySequence.fromMapKeys('a<C-B><A-C>d<M-e>').keys;
- expect(keys).to.have.lengthOf(5);
- expect(keys[0].key).to.equal('a');
- expect(keys[1].ctrl).to.be.true;
- expect(keys[1].key).to.equal('b');
- expect(keys[2].alt).to.be.true;
- expect(keys[2].key).to.equal('c');
- expect(keys[3].key).to.equal('d');
- expect(keys[4].meta).to.be.true;
- expect(keys[4].key).to.equal('e');
- });
- })
-});