blob: e12d78820c7c7f5e585ad51228e554550c969d06 (
plain) (
blame)
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
|
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;
});
});
});
|