aboutsummaryrefslogtreecommitdiff
path: root/test/content/operators/impls
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2021-09-30 00:16:32 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2021-09-30 00:24:35 +0900
commitacfe1b78009b0c3183cd69eebdabb458e2079b73 (patch)
tree20b6c71228976173f4086d34aec552feadb461fc /test/content/operators/impls
parentc843809ba29bd70c28b9a19e4cb3f1002edee781 (diff)
Move mock library to jest
Diffstat (limited to 'test/content/operators/impls')
-rw-r--r--test/content/operators/impls/FocusOperator.test.ts7
-rw-r--r--test/content/operators/impls/PasteOperator.test.ts22
-rw-r--r--test/content/operators/impls/StartFollowOperator.test.ts10
3 files changed, 19 insertions, 20 deletions
diff --git a/test/content/operators/impls/FocusOperator.test.ts b/test/content/operators/impls/FocusOperator.test.ts
index a0eb53b..2d72620 100644
--- a/test/content/operators/impls/FocusOperator.test.ts
+++ b/test/content/operators/impls/FocusOperator.test.ts
@@ -1,4 +1,3 @@
-import sinon from "sinon";
import FocusOperator from "../../../../src/content/operators/impls/FocusOperator";
import MockFocusPresenter from "../../mock/MockFocusPresenter";
@@ -6,12 +5,14 @@ describe("FocusOperator", () => {
describe("#run", () => {
it("focus a first input", async () => {
const presenter = new MockFocusPresenter();
- const mock = sinon.mock(presenter).expects("focusFirstElement");
+ const focusFirstElementSpy = jest
+ .spyOn(presenter, "focusFirstElement")
+ .mockReturnValue(true);
const sut = new FocusOperator(presenter);
await sut.run();
- mock.verify();
+ expect(focusFirstElementSpy).toBeCalled();
});
});
});
diff --git a/test/content/operators/impls/PasteOperator.test.ts b/test/content/operators/impls/PasteOperator.test.ts
index 8a3a374..fa42576 100644
--- a/test/content/operators/impls/PasteOperator.test.ts
+++ b/test/content/operators/impls/PasteOperator.test.ts
@@ -1,4 +1,3 @@
-import sinon from "sinon";
import PasteOperator from "../../../../src/content/operators/impls/PasteOperator";
import MockClipboardRepository from "../../mock/MockClipboardRepository";
import MockSettingRepository from "../../mock/MockSettingRepository";
@@ -10,10 +9,9 @@ describe("PasteOperator", () => {
const clipboardRepository = new MockClipboardRepository("apple");
const settingRepository = new MockSettingRepository();
const operationClient = new MockOperationClient();
- const mockOperationClient = sinon
- .mock(operationClient)
- .expects("internalOpenUrl")
- .withArgs("https://google.com/search?q=apple");
+ const internalOpenUrlSpy = jest
+ .spyOn(operationClient, "internalOpenUrl")
+ .mockReturnValue(Promise.resolve());
const sut = new PasteOperator(
clipboardRepository,
settingRepository,
@@ -23,7 +21,10 @@ describe("PasteOperator", () => {
await sut.run();
- mockOperationClient.verify();
+ expect(internalOpenUrlSpy).toBeCalledWith(
+ "https://google.com/search?q=apple",
+ false
+ );
});
it("open a url", async () => {
@@ -32,10 +33,9 @@ describe("PasteOperator", () => {
);
const settingRepository = new MockSettingRepository();
const operationClient = new MockOperationClient();
- const mockOperationClient = sinon
- .mock(operationClient)
- .expects("internalOpenUrl")
- .withArgs("https://example.com/");
+ const internalOpenUrlSpy = jest
+ .spyOn(operationClient, "internalOpenUrl")
+ .mockReturnValue(Promise.resolve());
const sut = new PasteOperator(
clipboardRepository,
settingRepository,
@@ -45,7 +45,7 @@ describe("PasteOperator", () => {
await sut.run();
- mockOperationClient.verify();
+ expect(internalOpenUrlSpy).toBeCalledWith("https://example.com/", false);
});
});
});
diff --git a/test/content/operators/impls/StartFollowOperator.test.ts b/test/content/operators/impls/StartFollowOperator.test.ts
index 8f9bd2d..4216cd0 100644
--- a/test/content/operators/impls/StartFollowOperator.test.ts
+++ b/test/content/operators/impls/StartFollowOperator.test.ts
@@ -1,4 +1,3 @@
-import sinon from "sinon";
import StartFollowOperator from "../../../../src/content/operators/impls/StartFollowOperator";
import MockFollowMasterClient from "../../mock/MockFollowMasterClient";
@@ -6,15 +5,14 @@ describe("StartFollowOperator", () => {
describe("#run", () => {
it("starts following links", async () => {
const client = new MockFollowMasterClient();
- const mock = sinon
- .mock(client)
- .expects("startFollow")
- .withArgs(true, false);
+ const startFollowSpy = jest
+ .spyOn(client, "startFollow")
+ .mockReturnValue();
const sut = new StartFollowOperator(client, true, false);
await sut.run();
- mock.verify();
+ expect(startFollowSpy).toBeCalledWith(true, false);
});
});
});