diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-10-10 01:42:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 01:42:37 +0000 |
commit | dfcefe1b84cc96ead1c8d8f9aa65ff05ccd70378 (patch) | |
tree | 12f1a4ed6da8fd96c034d23bcf08b1535bca1113 /test/background/operators/impls/RepeatLastOperator.test.ts | |
parent | 24f4f06db6572d81cadfe191f36c433a79985871 (diff) | |
parent | 039095e18562c44edda2c5a83a3d82c2e220b370 (diff) |
Merge pull request #1267 from ueokande/move-to-jest
Move to Jest
Diffstat (limited to 'test/background/operators/impls/RepeatLastOperator.test.ts')
-rw-r--r-- | test/background/operators/impls/RepeatLastOperator.test.ts | 25 |
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(); }); }); }); |