aboutsummaryrefslogtreecommitdiff
path: root/test/content/repositories/KeymapRepository.test.ts
blob: 8f0be67fbcd54614adc4f97354661a85e22ac016 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import KeymapRepository, { KeymapRepositoryImpl }
  from '../../../src/content/repositories/KeymapRepository';
import Key from '../../../src/content/domains/Key'
import { expect } from 'chai';

describe('KeymapRepositoryImpl', () => {
  let sut: KeymapRepository;

  before(() => {
    sut = new KeymapRepositoryImpl();
  });

  describe('#enqueueKey()', () => {
    it('enqueues keys', () => {
      sut.enqueueKey(Key.fromMapKey('a');
      sut.enqueueKey(Key.fromMapKey('b');
      let sequence = sut.enqueueKey(Key.fromMapKey('c'));

      let keys = sequence.getKeyArray();
      expect(keys[0].equals(Key.fromMapKey('a'))).to.be.true;
      expect(keys[1].equals(Key.fromMapKey('b'))).to.be.true;
      expect(keys[2].equals(Key.fromMapKey('c'))).to.be.true;
    });
  });

  describe('#clear()', () => {
    it('clears keys', () => {
      sut.enqueueKey(Key.fromMapKey('a');
      sut.enqueueKey(Key.fromMapKey('b');
      sut.enqueueKey(Key.fromMapKey('c');
      sut.clear();

      let sequence = sut.enqueueKey(Key.fromMapKey('a'));
      expect(sequence.length()).to.equal(1);
    });
  });
});