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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import PasteOperator from "../../../../src/content/operators/impls/PasteOperator";
import MockClipboardRepository from "../../mock/MockClipboardRepository";
import MockSettingRepository from "../../mock/MockSettingRepository";
import MockOperationClient from "../../mock/MockOperationClient";
describe("PasteOperator", () => {
describe("#run", () => {
it("open a search url", async () => {
const clipboardRepository = new MockClipboardRepository("apple");
const settingRepository = new MockSettingRepository();
const operationClient = new MockOperationClient();
const internalOpenUrlSpy = jest
.spyOn(operationClient, "internalOpenUrl")
.mockReturnValue(Promise.resolve());
const sut = new PasteOperator(
clipboardRepository,
settingRepository,
operationClient,
false
);
await sut.run();
expect(internalOpenUrlSpy).toBeCalledWith(
"https://google.com/search?q=apple",
false
);
});
it("open a url", async () => {
const clipboardRepository = new MockClipboardRepository(
"https://example.com/"
);
const settingRepository = new MockSettingRepository();
const operationClient = new MockOperationClient();
const internalOpenUrlSpy = jest
.spyOn(operationClient, "internalOpenUrl")
.mockReturnValue(Promise.resolve());
const sut = new PasteOperator(
clipboardRepository,
settingRepository,
operationClient,
false
);
await sut.run();
expect(internalOpenUrlSpy).toBeCalledWith("https://example.com/", false);
});
});
});
|