aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/content/mock/MockFindMasterClient.ts11
-rw-r--r--test/content/operators/impls/FindNextOperator.test.ts17
-rw-r--r--test/content/operators/impls/FindOperatorFactoryChain.test.ts21
-rw-r--r--test/content/operators/impls/FindPrevOperator.test.ts17
-rw-r--r--test/content/repositories/FindRepository.test.ts14
-rw-r--r--test/content/usecases/FindUseCase.test.ts160
6 files changed, 0 insertions, 240 deletions
diff --git a/test/content/mock/MockFindMasterClient.ts b/test/content/mock/MockFindMasterClient.ts
deleted file mode 100644
index a035cc5..0000000
--- a/test/content/mock/MockFindMasterClient.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import FindMasterClient from "../../../src/content/client/FindMasterClient";
-
-export default class MockFindMasterClient implements FindMasterClient {
- findNext(): void {
- throw new Error("not implemented");
- }
-
- findPrev(): void {
- throw new Error("not implemented");
- }
-}
diff --git a/test/content/operators/impls/FindNextOperator.test.ts b/test/content/operators/impls/FindNextOperator.test.ts
deleted file mode 100644
index d93d45e..0000000
--- a/test/content/operators/impls/FindNextOperator.test.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import sinon from "sinon";
-import FindNextOperator from "../../../../src/content/operators/impls/FindNextOperator";
-import MockFindMasterClient from "../../mock/MockFindMasterClient";
-
-describe("FindNextOperator", () => {
- describe("#run", () => {
- it("find next keyword", async () => {
- const client = new MockFindMasterClient();
- const mock = sinon.mock(client).expects("findNext").exactly(3);
- const sut = new FindNextOperator(client, 3);
-
- await sut.run();
-
- mock.verify();
- });
- });
-});
diff --git a/test/content/operators/impls/FindOperatorFactoryChain.test.ts b/test/content/operators/impls/FindOperatorFactoryChain.test.ts
deleted file mode 100644
index 6c599ae..0000000
--- a/test/content/operators/impls/FindOperatorFactoryChain.test.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import * as operations from "../../../../src/shared/operations";
-import { expect } from "chai";
-import FindOperatorFactoryChain from "../../../../src/content/operators/impls/FindOperatorFactoryChain";
-import MockFindMasterClient from "../../mock/MockFindMasterClient";
-import FindNextOperator from "../../../../src/content/operators/impls/FindNextOperator";
-import FindPrevOperator from "../../../../src/content/operators/impls/FindPrevOperator";
-
-describe("FindOperatorFactoryChain", () => {
- describe("#create", () => {
- it("returns an operator", () => {
- const sut = new FindOperatorFactoryChain(new MockFindMasterClient());
- expect(sut.create({ type: operations.FIND_NEXT }, 0)).to.be.instanceOf(
- FindNextOperator
- );
- expect(sut.create({ type: operations.FIND_PREV }, 0)).to.be.instanceOf(
- FindPrevOperator
- );
- expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null;
- });
- });
-});
diff --git a/test/content/operators/impls/FindPrevOperator.test.ts b/test/content/operators/impls/FindPrevOperator.test.ts
deleted file mode 100644
index 1ebde8d..0000000
--- a/test/content/operators/impls/FindPrevOperator.test.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import sinon from "sinon";
-import FindPrevOperator from "../../../../src/content/operators/impls/FindPrevOperator";
-import MockFindMasterClient from "../../mock/MockFindMasterClient";
-
-describe("FindPrevOperator", () => {
- describe("#run", () => {
- it("find previous keyword", async () => {
- const client = new MockFindMasterClient();
- const mock = sinon.mock(client).expects("findPrev").exactly(3);
- const sut = new FindPrevOperator(client, 3);
-
- await sut.run();
-
- mock.verify();
- });
- });
-});
diff --git a/test/content/repositories/FindRepository.test.ts b/test/content/repositories/FindRepository.test.ts
deleted file mode 100644
index e0abb9d..0000000
--- a/test/content/repositories/FindRepository.test.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { FindRepositoryImpl } from "../../../src/content/repositories/FindRepository";
-import { expect } from "chai";
-
-describe("FindRepositoryImpl", () => {
- it("updates and gets last keyword", () => {
- const sut = new FindRepositoryImpl();
-
- expect(sut.getLastKeyword()).to.be.null;
-
- sut.setLastKeyword("monkey");
-
- expect(sut.getLastKeyword()).to.equal("monkey");
- });
-});
diff --git a/test/content/usecases/FindUseCase.test.ts b/test/content/usecases/FindUseCase.test.ts
deleted file mode 100644
index b53ef74..0000000
--- a/test/content/usecases/FindUseCase.test.ts
+++ /dev/null
@@ -1,160 +0,0 @@
-import FindRepository from "../../../src/content/repositories/FindRepository";
-import FindPresenter from "../../../src/content/presenters/FindPresenter";
-import FindClient from "../../../src/content/client/FindClient";
-import FindUseCase from "../../../src/content/usecases/FindUseCase";
-import MockConsoleClient from "../mock/MockConsoleClient";
-import { expect } from "chai";
-
-class MockFindRepository implements FindRepository {
- public keyword: string | null;
-
- constructor() {
- this.keyword = null;
- }
-
- getLastKeyword(): string | null {
- return this.keyword;
- }
-
- setLastKeyword(keyword: string): void {
- this.keyword = keyword;
- }
-}
-
-class MockFindPresenter implements FindPresenter {
- public document: string;
-
- public highlighted: boolean;
-
- constructor() {
- this.document = "";
- this.highlighted = false;
- }
-
- find(keyword: string, _backward: boolean): boolean {
- const found = this.document.includes(keyword);
- this.highlighted = found;
- return found;
- }
-
- clearSelection(): void {
- this.highlighted = false;
- }
-}
-
-class MockFindClient implements FindClient {
- public keyword: string | null;
-
- constructor() {
- this.keyword = null;
- }
-
- getGlobalLastKeyword(): Promise<string | null> {
- return Promise.resolve(this.keyword);
- }
-
- setGlobalLastKeyword(keyword: string): Promise<void> {
- this.keyword = keyword;
- return Promise.resolve();
- }
-}
-
-describe("FindUseCase", () => {
- let repository: MockFindRepository;
- let presenter: MockFindPresenter;
- let client: MockFindClient;
- let consoleClient: MockConsoleClient;
- let sut: FindUseCase;
-
- beforeEach(() => {
- repository = new MockFindRepository();
- presenter = new MockFindPresenter();
- client = new MockFindClient();
- consoleClient = new MockConsoleClient();
- sut = new FindUseCase(presenter, repository, client, consoleClient);
- });
-
- describe("#startFind", () => {
- it("find next by ketword", async () => {
- presenter.document = "monkey punch";
-
- await sut.startFind("monkey");
-
- expect(await presenter.highlighted).to.be.true;
- expect(await consoleClient.text).to.equal("Pattern found: monkey");
- expect(await repository.getLastKeyword()).to.equal("monkey");
- expect(await client.getGlobalLastKeyword()).to.equal("monkey");
- });
-
- it("find next by last keyword", async () => {
- presenter.document = "gorilla kick";
- repository.keyword = "gorilla";
-
- await sut.startFind(undefined);
-
- expect(await presenter.highlighted).to.be.true;
- expect(await consoleClient.text).to.equal("Pattern found: gorilla");
- expect(await repository.getLastKeyword()).to.equal("gorilla");
- expect(await client.getGlobalLastKeyword()).to.equal("gorilla");
- });
-
- it("find next by global last keyword", async () => {
- presenter.document = "chimpanzee typing";
-
- repository.keyword = null;
- client.keyword = "chimpanzee";
-
- await sut.startFind(undefined);
-
- expect(await presenter.highlighted).to.be.true;
- expect(await consoleClient.text).to.equal("Pattern found: chimpanzee");
- expect(await repository.getLastKeyword()).to.equal("chimpanzee");
- expect(await client.getGlobalLastKeyword()).to.equal("chimpanzee");
- });
-
- it("find not found error", async () => {
- presenter.document = "zoo";
-
- await sut.startFind("giraffe");
-
- expect(await presenter.highlighted).to.be.false;
- expect(await consoleClient.text).to.equal("Pattern not found: giraffe");
- expect(await repository.getLastKeyword()).to.equal("giraffe");
- expect(await client.getGlobalLastKeyword()).to.equal("giraffe");
- });
-
- it("show errors when no last keywords", async () => {
- repository.keyword = null;
- client.keyword = null;
-
- await sut.startFind(undefined);
-
- expect(await consoleClient.text).to.equal("No previous search keywords");
- expect(await consoleClient.isError).to.be.true;
- });
- });
-
- describe("#findNext", () => {
- it("finds by last keyword", async () => {
- presenter.document = "monkey punch";
- repository.keyword = "monkey";
-
- await sut.findNext();
-
- expect(await presenter.highlighted).to.be.true;
- expect(await consoleClient.text).to.equal("Pattern found: monkey");
- });
-
- it("show errors when no last keywords", async () => {
- repository.keyword = null;
- client.keyword = null;
-
- await sut.findNext();
-
- expect(await consoleClient.text).to.equal("No previous search keywords");
- expect(await consoleClient.isError).to.be.true;
- });
- });
-
- describe("#findPrev", () => {});
-});