diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-08-17 22:33:46 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-08-17 22:33:46 +0900 |
commit | f1c920e0003238a8f319fd29cd7aea068fd4f231 (patch) | |
tree | 558bd4781dc943811e1d38405840b8279d7ee1ef /test | |
parent | 13fb726332e9638cb3fafc477cf9fe641cb906ce (diff) |
add HintKeyProducer
Diffstat (limited to 'test')
-rw-r--r-- | test/content/hint-key-producer.test.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/content/hint-key-producer.test.js b/test/content/hint-key-producer.test.js new file mode 100644 index 0000000..74fb462 --- /dev/null +++ b/test/content/hint-key-producer.test.js @@ -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]); + } + }); + }); +}); |