aboutsummaryrefslogtreecommitdiff
path: root/test/content/usecases/HintKeyProducer.test.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-11-28 10:22:26 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2020-12-09 23:08:59 +0900
commitfd2055e2702251c856f60214f150c78d558dcbf7 (patch)
treea6c69af81645cc064cda960e910383186c2a756c /test/content/usecases/HintKeyProducer.test.ts
parentd9de67e710adb7849a3d721524174c3f946d79c5 (diff)
Make HintKeyRepository
Diffstat (limited to 'test/content/usecases/HintKeyProducer.test.ts')
-rw-r--r--test/content/usecases/HintKeyProducer.test.ts33
1 files changed, 23 insertions, 10 deletions
diff --git a/test/content/usecases/HintKeyProducer.test.ts b/test/content/usecases/HintKeyProducer.test.ts
index f7e02ea..9d320b4 100644
--- a/test/content/usecases/HintKeyProducer.test.ts
+++ b/test/content/usecases/HintKeyProducer.test.ts
@@ -1,13 +1,7 @@
-import HintKeyProducer from "../../../src/content/usecases/HintKeyProducer";
+import { HintKeyRepositoryImpl } from "../../../src/content/repositories/HintKeyRepository";
import { expect } from "chai";
-describe("HintKeyProducer class", () => {
- describe("#constructor", () => {
- it("throws an exception on empty charset", () => {
- expect(() => new HintKeyProducer("")).to.throw(TypeError);
- });
- });
-
+describe("HintKeyProducerImpl class", () => {
describe("#produce", () => {
it("produce incremented keys", () => {
const charset = "abc";
@@ -30,10 +24,29 @@ describe("HintKeyProducer class", () => {
"aba",
];
- const producer = new HintKeyProducer(charset);
+ const sut = new HintKeyRepositoryImpl();
+ sut.reset(charset);
for (let i = 0; i < sequences.length; ++i) {
- expect(producer.produce()).to.equal(sequences[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);
+ });
+ });
});