aboutsummaryrefslogtreecommitdiff
path: root/test/background/mock/MockFindRepository.ts
blob: d5151f8367add7100a525f554e7b888135552aab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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();
  }

  deleteLocalState(tabId: number): Promise<void> {
    delete this.localStates[tabId];
    return Promise.resolve();
  }
}