diff options
Diffstat (limited to 'test/content/usecases/MarkUseCase.test.ts')
-rw-r--r-- | test/content/usecases/MarkUseCase.test.ts | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/test/content/usecases/MarkUseCase.test.ts b/test/content/usecases/MarkUseCase.test.ts index 494497a..df3f7bf 100644 --- a/test/content/usecases/MarkUseCase.test.ts +++ b/test/content/usecases/MarkUseCase.test.ts @@ -1,14 +1,14 @@ -import MarkRepository from '../../../src/content/repositories/MarkRepository'; -import { SettingRepositoryImpl } from '../../../src/content/repositories/SettingRepository'; -import MarkUseCase from '../../../src/content/usecases/MarkUseCase'; -import MarkClient from '../../../src/content/client/MarkClient'; -import MockConsoleClient from '../mock/MockConsoleClient'; -import MockScrollPresenter from '../mock/MockScrollPresenter'; -import Mark from '../../../src/content/domains/Mark'; -import { expect } from 'chai'; +import MarkRepository from "../../../src/content/repositories/MarkRepository"; +import { SettingRepositoryImpl } from "../../../src/content/repositories/SettingRepository"; +import MarkUseCase from "../../../src/content/usecases/MarkUseCase"; +import MarkClient from "../../../src/content/client/MarkClient"; +import MockConsoleClient from "../mock/MockConsoleClient"; +import MockScrollPresenter from "../mock/MockScrollPresenter"; +import Mark from "../../../src/content/domains/Mark"; +import { expect } from "chai"; class MockMarkRepository implements MarkRepository { - private current: {[key: string]: Mark}; + private current: { [key: string]: Mark }; constructor() { this.current = {}; @@ -24,12 +24,12 @@ class MockMarkRepository implements MarkRepository { } class MockMarkClient implements MarkClient { - public marks: {[key: string]: Mark}; + public marks: { [key: string]: Mark }; public last: string; constructor() { this.marks = {}; - this.last = ''; + this.last = ""; } setGloablMark(key: string, mark: Mark): Promise<void> { @@ -38,12 +38,12 @@ class MockMarkClient implements MarkClient { } jumpGlobalMark(key: string): Promise<void> { - this.last = key + this.last = key; return Promise.resolve(); } } -describe('MarkUseCase', () => { +describe("MarkUseCase", () => { let repository: MockMarkRepository; let client: MockMarkClient; let consoleClient: MockConsoleClient; @@ -60,53 +60,56 @@ describe('MarkUseCase', () => { client, repository, new SettingRepositoryImpl(), - consoleClient, + consoleClient ); }); - describe('#set', () => { - it('sets local mark', async() => { + describe("#set", () => { + it("sets local mark", async () => { scrollPresenter.scrollTo(10, 20, false); - await sut.set('x'); + await sut.set("x"); - expect(repository.get('x')).to.deep.equals({ x: 10, y: 20 }); + expect(repository.get("x")).to.deep.equals({ x: 10, y: 20 }); expect(consoleClient.text).to.equal("Set local mark to 'x'"); }); - it('sets global mark', async() => { + it("sets global mark", async () => { scrollPresenter.scrollTo(30, 40, false); - await sut.set('Z'); + await sut.set("Z"); - expect(client.marks['Z']).to.deep.equals({ x: 30, y: 40 }); + expect(client.marks["Z"]).to.deep.equals({ x: 30, y: 40 }); expect(consoleClient.text).to.equal("Set global mark to 'Z'"); }); }); - describe('#jump', () => { - it('jumps to local mark', async() => { - repository.set('x', { x: 20, y: 40 }); + describe("#jump", () => { + it("jumps to local mark", async () => { + repository.set("x", { x: 20, y: 40 }); - await sut.jump('x'); + await sut.jump("x"); expect(scrollPresenter.getScroll()).to.deep.equals({ x: 20, y: 40 }); }); - it('throws an error when no local marks', () => { - return sut.jump('a').then(() => { - throw new Error('error'); - }).catch((e) => { - expect(e).to.be.instanceof(Error); - }) - }) + it("throws an error when no local marks", () => { + return sut + .jump("a") + .then(() => { + throw new Error("error"); + }) + .catch((e) => { + expect(e).to.be.instanceof(Error); + }); + }); - it('jumps to global mark', async() => { - client.marks['Z'] = { x: 20, y: 0 }; + it("jumps to global mark", async () => { + client.marks["Z"] = { x: 20, y: 0 }; - await sut.jump('Z'); + await sut.jump("Z"); - expect(client.last).to.equal('Z') + expect(client.last).to.equal("Z"); }); }); }); |