add HintKeyProducer
This commit is contained in:
parent
13fb726332
commit
f1c920e000
2 changed files with 58 additions and 0 deletions
25
test/content/hint-key-producer.test.js
Normal file
25
test/content/hint-key-producer.test.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { expect } from "chai";
|
||||
import HintKeyProducer from '../../src/content/hint-key-producer';
|
||||
|
||||
describe('HintKeyProducer class', () => {
|
||||
describe('#constructor', () => {
|
||||
it('throws an exception on empty charset', () => {
|
||||
expect(() => new HintKeyProducer([])).to.throw(TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#produce', () => {
|
||||
it('produce incremented keys', () => {
|
||||
let charset = 'abc';
|
||||
let sequences = [
|
||||
'a', 'b', 'c',
|
||||
'aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc',
|
||||
'aaa', 'aab', 'aac', 'aba']
|
||||
|
||||
let producer = new HintKeyProducer(charset);
|
||||
for (let i = 0; i < sequences.length; ++i) {
|
||||
expect(producer.produce()).to.equal(sequences[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Reference in a new issue