aboutsummaryrefslogtreecommitdiff
path: root/test/content/repositories/KeymapRepository.test.ts
blob: 34704d97aec6571e9781e7393b4ba7e423c933f1 (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
import KeymapRepository, { KeymapRepositoryImpl }
  from '../../../src/content/repositories/KeymapRepository';
import { expect } from 'chai';

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

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

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

      expect(sequence.getKeyArray()).deep.equals([
        { key: 'a' }, { key: 'b' }, { key: 'c' },
      ]);
    });
  });

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

      let sequence = sut.enqueueKey({ key: 'a' });
      expect(sequence.length()).to.equal(1);
    });
  });
});