diff options
Diffstat (limited to 'test/background/operators/impls/RepeatOperatorFactoryChain.test.ts')
-rw-r--r-- | test/background/operators/impls/RepeatOperatorFactoryChain.test.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/background/operators/impls/RepeatOperatorFactoryChain.test.ts b/test/background/operators/impls/RepeatOperatorFactoryChain.test.ts new file mode 100644 index 0000000..e12d788 --- /dev/null +++ b/test/background/operators/impls/RepeatOperatorFactoryChain.test.ts @@ -0,0 +1,32 @@ +import "reflect-metadata"; +import { expect } from "chai"; +import RepeatOperatorFactoryChain from "../../../../src/background/operators/impls/RepeatOperatorFactoryChain"; +import RepeatLastOperator from "../../../../src/background/operators/impls/RepeatLastOperator"; +import OperatorFactory from "../../../../src/background/operators/OperatorFactory"; +import MockRepeatRepository from "../../mock/MockRepeatRepository"; +import Operator from "../../../../src/content/operators/Operator"; +import * as operations from "../../../../src/shared/operations"; + +class MockOperatorFactory implements OperatorFactory { + create(_op: operations.Operation): Operator { + throw new Error("not implemented"); + } +} + +describe("RepeatOperatorFactoryChain", () => { + describe("#create", () => { + it("returns a operator for the operation", async () => { + const repeatRepository = new MockRepeatRepository(); + const operatorFactory = new MockOperatorFactory(); + const sut = new RepeatOperatorFactoryChain( + repeatRepository, + operatorFactory + ); + + expect(sut.create({ type: operations.REPEAT_LAST })).to.be.instanceOf( + RepeatLastOperator + ); + expect(sut.create({ type: operations.CANCEL })).to.be.null; + }); + }); +}); |