aboutsummaryrefslogtreecommitdiff
path: root/test/background/operators/impls/RepeatLastOperator.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/background/operators/impls/RepeatLastOperator.test.ts')
-rw-r--r--test/background/operators/impls/RepeatLastOperator.test.ts25
1 files changed, 11 insertions, 14 deletions
diff --git a/test/background/operators/impls/RepeatLastOperator.test.ts b/test/background/operators/impls/RepeatLastOperator.test.ts
index 57f1227..fc37615 100644
--- a/test/background/operators/impls/RepeatLastOperator.test.ts
+++ b/test/background/operators/impls/RepeatLastOperator.test.ts
@@ -3,7 +3,6 @@ import MockRepeatRepository from "../../mock/MockRepeatRepository";
import OperatorFactory from "../../../../src/background/operators/OperatorFactory";
import * as operations from "../../../../src/shared/operations";
import Operator from "../../../../src/background/operators/Operator";
-import sinon from "sinon";
class MockOperatorFactory implements OperatorFactory {
create(_op: operations.Operation): Operator {
@@ -21,36 +20,34 @@ describe("RepeatLastOperator", () => {
describe("#run", () => {
it("repeat last operation", async () => {
const operator = new MockOperator();
- const operatorMock = sinon.mock(operator).expects("run").once();
+ const runSpy = jest
+ .spyOn(operator, "run")
+ .mockReturnValue(Promise.resolve());
+
const repeatRepository = new MockRepeatRepository();
repeatRepository.setLastOperation({ type: operations.CANCEL });
const operatorFactory = new MockOperatorFactory();
- const operatorFactoryMock = sinon
- .mock(operatorFactory)
- .expects("create")
- .withArgs({ type: operations.CANCEL });
- operatorFactoryMock.returns(operator);
+ const createSpy = jest
+ .spyOn(operatorFactory, "create")
+ .mockReturnValue(operator);
const sut = new RepeatLastOperator(repeatRepository, operatorFactory);
await sut.run();
- operatorFactoryMock.verify();
- operatorMock.verify();
+ expect(runSpy).toBeCalledTimes(1);
+ expect(createSpy).toBeCalledWith({ type: operations.CANCEL });
});
it("does nothing if no last operations", async () => {
const repeatRepository = new MockRepeatRepository();
const operatorFactory = new MockOperatorFactory();
- const operatorFactoryMock = sinon
- .mock(operatorFactory)
- .expects("create")
- .never();
+ const createSpy = jest.spyOn(operatorFactory, "create");
const sut = new RepeatLastOperator(repeatRepository, operatorFactory);
await sut.run();
- operatorFactoryMock.verify();
+ expect(createSpy).not.toBeCalled();
});
});
});