diff options
Diffstat (limited to 'test/content/usecases/HintKeyProducer.test.ts')
-rw-r--r-- | test/content/usecases/HintKeyProducer.test.ts | 33 |
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); + }); + }); }); |