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
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import { HintKeyRepositoryImpl } from "../../../src/content/repositories/HintKeyRepository";
import { expect } from "chai";
describe("HintKeyProducerImpl class", () => {
describe("#produce", () => {
it("produce incremented keys", () => {
const charset = "abc";
const sequences = [
"a",
"b",
"c",
"aa",
"ab",
"ac",
"ba",
"bb",
"bc",
"ca",
"cb",
"cc",
"aaa",
"aab",
"aac",
"aba",
];
const sut = new HintKeyRepositoryImpl();
sut.reset(charset);
for (let i = 0; i < sequences.length; ++i) {
expect(sut.produce()).to.equal(sequences[i]);
}
});
});
describe("#reset", () => {
it("resets charset", () => {
const sut = new HintKeyRepositoryImpl();
sut.reset("ab");
expect(sut.produce()).to.equal("a");
expect(sut.produce()).to.equal("b");
sut.reset("xy");
expect(sut.produce()).to.equal("x");
expect(sut.produce()).to.equal("y");
});
it("throws an exception on empty charset", () => {
const sut = new HintKeyRepositoryImpl();
expect(() => sut.reset("")).to.throw(TypeError);
});
});
});
|