From 38a69e4ca319f9db3c54a5cb69cd5645f12369d5 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 10 Dec 2019 21:45:16 +0900 Subject: Add prefix functions in KeySequence --- test/shared/settings/KeySequence.test.ts | 103 ------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 test/shared/settings/KeySequence.test.ts (limited to 'test/shared') diff --git a/test/shared/settings/KeySequence.test.ts b/test/shared/settings/KeySequence.test.ts deleted file mode 100644 index 8a7a350..0000000 --- a/test/shared/settings/KeySequence.test.ts +++ /dev/null @@ -1,103 +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('')); - - 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(''), - ]); - - 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(''), - ]))).to.be.true; - expect(seq.startsWith(new KeySequence([ - Key.fromMapKey('g'), Key.fromMapKey(''), 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('#isDigitOnly', () => { - it('returns true the keys are only digits', () => { - expect(new KeySequence([ - new Key({ key: '4' }), - new Key({ key: '0' }), - ]).isDigitOnly()).to.be.true; - expect(new KeySequence([ - new Key({ key: '4' }), - new Key({ key: '0' }), - new Key({ key: 'z' }), - ]).isDigitOnly()).to.be.false; - }) - }); - - describe('#splitNumericPrefix', () => { - it('splits numeric prefix', () => { - expect(KeySequence.fromMapKeys('10gg').splitNumericPrefix()).to.deep.equal([ - KeySequence.fromMapKeys('10'), - KeySequence.fromMapKeys('gg'), - ]); - expect(KeySequence.fromMapKeys('10').splitNumericPrefix()).to.deep.equal([ - KeySequence.fromMapKeys('10'), - new KeySequence([]), - ]); - expect(KeySequence.fromMapKeys('gg').splitNumericPrefix()).to.deep.equal([ - new KeySequence([]), - KeySequence.fromMapKeys('gg'), - ]); - }); - }); - - describe('#fromMapKeys', () => { - it('returns mapped keys for Shift+Esc', () => { - let keys = KeySequence.fromMapKeys('').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 ad', () => { - let keys = KeySequence.fromMapKeys('ad').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'); - }); - }) -}); -- cgit v1.2.3