diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-06-14 23:14:51 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-07-05 21:32:43 +0900 |
commit | 65cf6f0842d8d5933dc13b3767b1baf398d68cd5 (patch) | |
tree | df9a8b139fd98adb79f075ba655d1303bdf3fd1d /test/background/mock | |
parent | caced372415a944c4297157397d0027ba629fff0 (diff) |
Implement FindNextOperator
Diffstat (limited to 'test/background/mock')
-rw-r--r-- | test/background/mock/MockFindClient.ts | 24 | ||||
-rw-r--r-- | test/background/mock/MockFindRepository.ts | 26 |
2 files changed, 50 insertions, 0 deletions
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<void> { + throw new Error("not implemented"); + } + + removeHighlights(): Promise<void> { + throw new Error("not implemented"); + } + + selectKeyword( + _tabId: number, + _rangeData: browser.find.RangeData + ): Promise<void> { + throw new Error("not implemented"); + } + + startFind(_keyword: string): Promise<FindResult> { + 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<string | undefined> { + return Promise.resolve(this.globalKeyword); + } + + setGlobalKeyword(keyword: string): Promise<void> { + this.globalKeyword = keyword; + return Promise.resolve(); + } + + getLocalState(tabId: number): Promise<FindState | undefined> { + return Promise.resolve(this.localStates[tabId]); + } + + setLocalState(tabId: number, state: FindState): Promise<void> { + this.localStates[tabId] = state; + return Promise.resolve(); + } +} |