From 65cf6f0842d8d5933dc13b3767b1baf398d68cd5 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 14 Jun 2021 23:14:51 +0900 Subject: Implement FindNextOperator --- test/background/mock/MockFindClient.ts | 24 ++++++++++++++++++++++++ test/background/mock/MockFindRepository.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/background/mock/MockFindClient.ts create mode 100644 test/background/mock/MockFindRepository.ts (limited to 'test/background/mock') diff --git a/test/background/mock/MockFindClient.ts b/test/background/mock/MockFindClient.ts new file mode 100644 index 0000000..bd25a27 --- /dev/null +++ b/test/background/mock/MockFindClient.ts @@ -0,0 +1,24 @@ +import FindClient, { + FindResult, +} from "../../../src/background/clients/FindClient"; + +export default class MockFindClient implements FindClient { + highlightAll(): Promise { + throw new Error("not implemented"); + } + + removeHighlights(): Promise { + throw new Error("not implemented"); + } + + selectKeyword( + _tabId: number, + _rangeData: browser.find.RangeData + ): Promise { + throw new Error("not implemented"); + } + + startFind(_keyword: string): Promise { + throw new Error("not implemented"); + } +} diff --git a/test/background/mock/MockFindRepository.ts b/test/background/mock/MockFindRepository.ts new file mode 100644 index 0000000..af552c8 --- /dev/null +++ b/test/background/mock/MockFindRepository.ts @@ -0,0 +1,26 @@ +import FindRepository, { + FindState, +} from "../../../src/background/repositories/FindRepository"; + +export default class MockFindRepository implements FindRepository { + private globalKeyword: string | undefined; + private localStates: { [tabId: number]: FindState } = {}; + + getGlobalKeyword(): Promise { + return Promise.resolve(this.globalKeyword); + } + + setGlobalKeyword(keyword: string): Promise { + this.globalKeyword = keyword; + return Promise.resolve(); + } + + getLocalState(tabId: number): Promise { + return Promise.resolve(this.localStates[tabId]); + } + + setLocalState(tabId: number, state: FindState): Promise { + this.localStates[tabId] = state; + return Promise.resolve(); + } +} -- cgit v1.2.3