aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/content/usecases/ClipboardUseCase.ts34
-rw-r--r--src/content/usecases/FindSlaveUseCase.ts17
-rw-r--r--src/content/usecases/FocusUseCase.ts11
-rw-r--r--src/content/usecases/MarkKeyUseCase.ts8
-rw-r--r--src/content/usecases/ScrollUseCase.ts51
-rw-r--r--test/content/usecases/ClipboardUseCase.test.ts95
6 files changed, 0 insertions, 216 deletions
diff --git a/src/content/usecases/ClipboardUseCase.ts b/src/content/usecases/ClipboardUseCase.ts
deleted file mode 100644
index 875fc11..0000000
--- a/src/content/usecases/ClipboardUseCase.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { injectable, inject } from "tsyringe";
-import * as urls from "../../shared/urls";
-import ClipboardRepository from "../repositories/ClipboardRepository";
-import SettingRepository from "../repositories/SettingRepository";
-import ConsoleClient from "../client/ConsoleClient";
-import OperationClient from "../client/OperationClient";
-
-@injectable()
-export default class ClipboardUseCase {
- constructor(
- @inject("ClipboardRepository") private repository: ClipboardRepository,
- @inject("SettingRepository") private settingRepository: SettingRepository,
- @inject("ConsoleClient") private consoleClient: ConsoleClient,
- @inject("OperationClient") private operationClinet: OperationClient
- ) {}
-
- async yankCurrentURL(): Promise<string> {
- const url = window.location.href;
- this.repository.write(url);
- await this.consoleClient.info("Yanked " + url);
- return Promise.resolve(url);
- }
-
- async openOrSearch(newTab: boolean): Promise<void> {
- const search = this.settingRepository.get().search;
- const text = this.repository.read();
- const url = urls.searchUrl(text, search);
-
- // TODO: Repeat pasting from clipboard instead of opening a certain url.
- // 'Repeat last' command is implemented in the background script and cannot
- // access to clipboard until Firefox 63.
- await this.operationClinet.internalOpenUrl(url, newTab);
- }
-}
diff --git a/src/content/usecases/FindSlaveUseCase.ts b/src/content/usecases/FindSlaveUseCase.ts
deleted file mode 100644
index 3b8c4b4..0000000
--- a/src/content/usecases/FindSlaveUseCase.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { injectable, inject } from "tsyringe";
-import FindMasterClient from "../client/FindMasterClient";
-
-@injectable()
-export default class FindSlaveUseCase {
- constructor(
- @inject("FindMasterClient") private findMasterClient: FindMasterClient
- ) {}
-
- findNext() {
- this.findMasterClient.findNext();
- }
-
- findPrev() {
- this.findMasterClient.findPrev();
- }
-}
diff --git a/src/content/usecases/FocusUseCase.ts b/src/content/usecases/FocusUseCase.ts
deleted file mode 100644
index 8c62003..0000000
--- a/src/content/usecases/FocusUseCase.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { injectable, inject } from "tsyringe";
-import FocusPresenter from "../presenters/FocusPresenter";
-
-@injectable()
-export default class FocusUseCases {
- constructor(@inject("FocusPresenter") private presenter: FocusPresenter) {}
-
- focusFirstInput() {
- this.presenter.focusFirstElement();
- }
-}
diff --git a/src/content/usecases/MarkKeyUseCase.ts b/src/content/usecases/MarkKeyUseCase.ts
index b807c74..61ed135 100644
--- a/src/content/usecases/MarkKeyUseCase.ts
+++ b/src/content/usecases/MarkKeyUseCase.ts
@@ -15,18 +15,10 @@ export default class MarkKeyUseCase {
return this.repository.isJumpMode();
}
- enableSetMode(): void {
- this.repository.enableSetMode();
- }
-
disableSetMode(): void {
this.repository.disabeSetMode();
}
- enableJumpMode(): void {
- this.repository.enableJumpMode();
- }
-
disableJumpMode(): void {
this.repository.disabeJumpMode();
}
diff --git a/src/content/usecases/ScrollUseCase.ts b/src/content/usecases/ScrollUseCase.ts
deleted file mode 100644
index 319c8b4..0000000
--- a/src/content/usecases/ScrollUseCase.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { injectable, inject } from "tsyringe";
-import ScrollPresenter from "../presenters/ScrollPresenter";
-import SettingRepository from "../repositories/SettingRepository";
-
-@injectable()
-export default class ScrollUseCase {
- constructor(
- @inject("ScrollPresenter") private presenter: ScrollPresenter,
- @inject("SettingRepository") private settingRepository: SettingRepository
- ) {}
-
- scrollVertically(count: number): void {
- const smooth = this.getSmoothScroll();
- this.presenter.scrollVertically(count, smooth);
- }
-
- scrollHorizonally(count: number): void {
- const smooth = this.getSmoothScroll();
- this.presenter.scrollHorizonally(count, smooth);
- }
-
- scrollPages(count: number): void {
- const smooth = this.getSmoothScroll();
- this.presenter.scrollPages(count, smooth);
- }
-
- scrollToTop(): void {
- const smooth = this.getSmoothScroll();
- this.presenter.scrollToTop(smooth);
- }
-
- scrollToBottom(): void {
- const smooth = this.getSmoothScroll();
- this.presenter.scrollToBottom(smooth);
- }
-
- scrollToHome(): void {
- const smooth = this.getSmoothScroll();
- this.presenter.scrollToHome(smooth);
- }
-
- scrollToEnd(): void {
- const smooth = this.getSmoothScroll();
- this.presenter.scrollToEnd(smooth);
- }
-
- private getSmoothScroll(): boolean {
- const settings = this.settingRepository.get();
- return settings.properties.smoothscroll;
- }
-}
diff --git a/test/content/usecases/ClipboardUseCase.test.ts b/test/content/usecases/ClipboardUseCase.test.ts
deleted file mode 100644
index 5de3e69..0000000
--- a/test/content/usecases/ClipboardUseCase.test.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-import ClipboardRepository from "../../../src/content/repositories/ClipboardRepository";
-import { SettingRepositoryImpl } from "../../../src/content/repositories/SettingRepository";
-import ClipboardUseCase from "../../../src/content/usecases/ClipboardUseCase";
-import OperationClient from "../../../src/content/client/OperationClient";
-import ConsoleClient from "../../../src/content/client/ConsoleClient";
-
-import * as sinon from "sinon";
-import { expect } from "chai";
-import { Operation } from "../../../src/shared/operations";
-
-describe("ClipboardUseCase", () => {
- let clipboardRepository: ClipboardRepository;
-
- let operationClient: OperationClient;
-
- let consoleClient: ConsoleClient;
-
- let sut: ClipboardUseCase;
-
- beforeEach(() => {
- clipboardRepository = new (class implements ClipboardRepository {
- read(): string {
- return "";
- }
- write(_text: string) {}
- })();
- operationClient = new (class implements OperationClient {
- execBackgroundOp(_repeat: number, _op: Operation): Promise<void> {
- return Promise.resolve();
- }
- internalOpenUrl(
- _url: string,
- _newTab?: boolean,
- _background?: boolean
- ): Promise<void> {
- return Promise.resolve();
- }
- })();
- consoleClient = new (class implements ConsoleClient {
- error(_text: string): Promise<void> {
- return Promise.resolve();
- }
- info(_text: string): Promise<void> {
- return Promise.resolve();
- }
- })();
-
- sut = new ClipboardUseCase(
- clipboardRepository,
- new SettingRepositoryImpl(),
- consoleClient,
- operationClient
- );
- });
-
- describe("#yankCurrentURL", () => {
- it("yanks current url", async () => {
- const href = window.location.href;
- const mockRepository = sinon.mock(clipboardRepository);
- mockRepository.expects("write").withArgs(href);
- const mockConsoleClient = sinon.mock(consoleClient);
- mockConsoleClient.expects("info").withArgs("Yanked " + href);
-
- const yanked = await sut.yankCurrentURL();
-
- expect(yanked).to.equal(href);
- mockRepository.verify();
- mockConsoleClient.verify();
- });
- });
-
- describe("#openOrSearch", () => {
- it("opens url from the clipboard", async () => {
- const url = "https://github.com/ueokande/vim-vixen";
- sinon.stub(clipboardRepository, "read").returns(url);
- const mockOperationClient = sinon.mock(operationClient);
- mockOperationClient.expects("internalOpenUrl").withArgs(url, true);
-
- await sut.openOrSearch(true);
-
- mockOperationClient.verify();
- });
-
- it("opens search results from the clipboard", async () => {
- const url = "https://google.com/search?q=banana";
- sinon.stub(clipboardRepository, "read").returns("banana");
- const mockOperationClient = sinon.mock(operationClient);
- mockOperationClient.expects("internalOpenUrl").withArgs(url, true);
-
- await sut.openOrSearch(true);
-
- mockOperationClient.verify();
- });
- });
-});