From f1c920e0003238a8f319fd29cd7aea068fd4f231 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Thu, 17 Aug 2017 22:33:46 +0900 Subject: add HintKeyProducer --- test/content/hint-key-producer.test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/content/hint-key-producer.test.js (limited to 'test/content/hint-key-producer.test.js') 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]); + } + }); + }); +}); -- cgit v1.2.3