aboutsummaryrefslogtreecommitdiff
path: root/test/content/usecases/FindUseCase.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/content/usecases/FindUseCase.test.ts')
-rw-r--r--test/content/usecases/FindUseCase.test.ts87
1 files changed, 43 insertions, 44 deletions
diff --git a/test/content/usecases/FindUseCase.test.ts b/test/content/usecases/FindUseCase.test.ts
index 3978dbc..b53ef74 100644
--- a/test/content/usecases/FindUseCase.test.ts
+++ b/test/content/usecases/FindUseCase.test.ts
@@ -1,9 +1,9 @@
-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';
+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;
@@ -27,7 +27,7 @@ class MockFindPresenter implements FindPresenter {
public highlighted: boolean;
constructor() {
- this.document = '';
+ this.document = "";
this.highlighted = false;
}
@@ -59,7 +59,7 @@ class MockFindClient implements FindClient {
}
}
-describe('FindUseCase', () => {
+describe("FindUseCase", () => {
let repository: MockFindRepository;
let presenter: MockFindPresenter;
let client: MockFindClient;
@@ -74,88 +74,87 @@ describe('FindUseCase', () => {
sut = new FindUseCase(presenter, repository, client, consoleClient);
});
- describe('#startFind', () => {
- it('find next by ketword', async() => {
- presenter.document = 'monkey punch';
+ describe("#startFind", () => {
+ it("find next by ketword", async () => {
+ presenter.document = "monkey punch";
- await sut.startFind('monkey');
+ 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');
+ 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';
+ 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');
+ 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';
+ it("find next by global last keyword", async () => {
+ presenter.document = "chimpanzee typing";
repository.keyword = null;
- client.keyword = 'chimpanzee';
+ 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');
+ 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';
+ it("find not found error", async () => {
+ presenter.document = "zoo";
- await sut.startFind('giraffe');
+ 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');
+ 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() => {
+ 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.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';
+ 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');
+ expect(await consoleClient.text).to.equal("Pattern found: monkey");
});
- it('show errors when no last keywords', async() => {
+ 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.text).to.equal("No previous search keywords");
expect(await consoleClient.isError).to.be.true;
});
});
- describe('#findPrev', () => {
- });
+ describe("#findPrev", () => {});
});