diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-12-10 12:52:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 12:52:17 +0000 |
commit | 5a0444d7bb7eae27fdca5c2be8fc3ec6c36d53bd (patch) | |
tree | 46d70e19f9720d237f4423c1debfcacdd088ce0b /test/content/mock | |
parent | a3c34a309c4b1421eb4914c3fbeba327a5400021 (diff) | |
parent | d2fb674566393d9a8b88d71dba9f5081786b118c (diff) |
Merge pull request #917 from ueokande/operation-as-a-operator
refactor: Make each operation as an operator
Diffstat (limited to 'test/content/mock')
-rw-r--r-- | test/content/mock/MockAddonEnabledRepository.ts | 18 | ||||
-rw-r--r-- | test/content/mock/MockAddonIndicatorClient.ts | 13 | ||||
-rw-r--r-- | test/content/mock/MockClipboardRepository.ts | 16 | ||||
-rw-r--r-- | test/content/mock/MockFindMasterClient.ts | 11 | ||||
-rw-r--r-- | test/content/mock/MockFocusPresenter.ts | 7 | ||||
-rw-r--r-- | test/content/mock/MockFollowMasterClient.ts | 16 | ||||
-rw-r--r-- | test/content/mock/MockMarkKeyRepository.ts | 43 | ||||
-rw-r--r-- | test/content/mock/MockOperationClient.ts | 16 | ||||
-rw-r--r-- | test/content/mock/MockScrollPresenter.ts | 6 | ||||
-rw-r--r-- | test/content/mock/MockSettingRepository.ts | 20 | ||||
-rw-r--r-- | test/content/mock/MockURLRepository.ts | 9 |
11 files changed, 172 insertions, 3 deletions
diff --git a/test/content/mock/MockAddonEnabledRepository.ts b/test/content/mock/MockAddonEnabledRepository.ts new file mode 100644 index 0000000..cbe248b --- /dev/null +++ b/test/content/mock/MockAddonEnabledRepository.ts @@ -0,0 +1,18 @@ +import AddonEnabledRepository from "../../../src/content/repositories/AddonEnabledRepository"; + +export default class MockAddonEnabledRepository + implements AddonEnabledRepository { + public enabled: boolean; + + constructor(initialValue = false) { + this.enabled = initialValue; + } + + get(): boolean { + return this.enabled; + } + + set(on: boolean): void { + this.enabled = on; + } +} diff --git a/test/content/mock/MockAddonIndicatorClient.ts b/test/content/mock/MockAddonIndicatorClient.ts new file mode 100644 index 0000000..6ea9798 --- /dev/null +++ b/test/content/mock/MockAddonIndicatorClient.ts @@ -0,0 +1,13 @@ +import AddonIndicatorClient from "../../../src/content/client/AddonIndicatorClient"; + +export default class MockAddonIndicatorClient implements AddonIndicatorClient { + public enabled: boolean; + + constructor(initialValue = false) { + this.enabled = initialValue; + } + + async setEnabled(enabled: boolean): Promise<void> { + this.enabled = enabled; + } +} diff --git a/test/content/mock/MockClipboardRepository.ts b/test/content/mock/MockClipboardRepository.ts new file mode 100644 index 0000000..c6e53bd --- /dev/null +++ b/test/content/mock/MockClipboardRepository.ts @@ -0,0 +1,16 @@ +import ClipboardRepository from "../../../src/content/repositories/ClipboardRepository"; + +export default class MockClipboardRepository implements ClipboardRepository { + private value: string; + + constructor(initValue = "") { + this.value = initValue; + } + read(): string { + return this.value; + } + + write(text: string): void { + this.value = text; + } +} diff --git a/test/content/mock/MockFindMasterClient.ts b/test/content/mock/MockFindMasterClient.ts new file mode 100644 index 0000000..a035cc5 --- /dev/null +++ b/test/content/mock/MockFindMasterClient.ts @@ -0,0 +1,11 @@ +import FindMasterClient from "../../../src/content/client/FindMasterClient"; + +export default class MockFindMasterClient implements FindMasterClient { + findNext(): void { + throw new Error("not implemented"); + } + + findPrev(): void { + throw new Error("not implemented"); + } +} diff --git a/test/content/mock/MockFocusPresenter.ts b/test/content/mock/MockFocusPresenter.ts new file mode 100644 index 0000000..43454d0 --- /dev/null +++ b/test/content/mock/MockFocusPresenter.ts @@ -0,0 +1,7 @@ +import FocusPresenter from "../../../src/content/presenters/FocusPresenter"; + +export default class MockFocusPresenter implements FocusPresenter { + focusFirstElement(): boolean { + throw new Error("not implemented"); + } +} diff --git a/test/content/mock/MockFollowMasterClient.ts b/test/content/mock/MockFollowMasterClient.ts new file mode 100644 index 0000000..fc660d5 --- /dev/null +++ b/test/content/mock/MockFollowMasterClient.ts @@ -0,0 +1,16 @@ +import FollowMasterClient from "../../../src/content/client/FollowMasterClient"; +import Key from "../../../src/shared/settings/Key"; + +export default class MockFollowMasterClient implements FollowMasterClient { + responseHintCount(_count: number): void { + throw new Error("not implemented"); + } + + sendKey(_key: Key): void { + throw new Error("not implemented"); + } + + startFollow(_newTab: boolean, _background: boolean): void { + throw new Error("not implemented"); + } +} diff --git a/test/content/mock/MockMarkKeyRepository.ts b/test/content/mock/MockMarkKeyRepository.ts new file mode 100644 index 0000000..12bc75c --- /dev/null +++ b/test/content/mock/MockMarkKeyRepository.ts @@ -0,0 +1,43 @@ +import MarkKeyRepository from "../../../src/content/repositories/MarkKeyRepository"; + +export default class MockMarkKeyRepository implements MarkKeyRepository { + public jumpMode: boolean; + public setMode: boolean; + + constructor( + initialValue: { + jumpMode: boolean; + setMode: boolean; + } = { + jumpMode: false, + setMode: false, + } + ) { + this.jumpMode = initialValue.jumpMode; + this.setMode = initialValue.setMode; + } + + disabeJumpMode(): void { + this.jumpMode = false; + } + + disabeSetMode(): void { + this.setMode = false; + } + + enableJumpMode(): void { + this.jumpMode = true; + } + + enableSetMode(): void { + this.setMode = true; + } + + isJumpMode(): boolean { + return this.jumpMode; + } + + isSetMode(): boolean { + return this.setMode; + } +} diff --git a/test/content/mock/MockOperationClient.ts b/test/content/mock/MockOperationClient.ts new file mode 100644 index 0000000..2f50f77 --- /dev/null +++ b/test/content/mock/MockOperationClient.ts @@ -0,0 +1,16 @@ +import OperationClient from "../../../src/content/client/OperationClient"; +import * as operations from "../../../src/shared/operations"; + +export default class MockOperationClient implements OperationClient { + execBackgroundOp(_repeat: number, _op: operations.Operation): Promise<void> { + throw new Error("not implemented"); + } + + internalOpenUrl( + _url: string, + _newTab?: boolean, + _background?: boolean + ): Promise<void> { + throw new Error("not implemented"); + } +} diff --git a/test/content/mock/MockScrollPresenter.ts b/test/content/mock/MockScrollPresenter.ts index c802227..8b4cf2a 100644 --- a/test/content/mock/MockScrollPresenter.ts +++ b/test/content/mock/MockScrollPresenter.ts @@ -3,10 +3,10 @@ import ScrollPresenter, { } from "../../../src/content/presenters/ScrollPresenter"; export default class MockScrollPresenter implements ScrollPresenter { - private pos: Point; + private readonly pos: Point; - constructor() { - this.pos = { x: 0, y: 0 }; + constructor(initX = 0, initY = 0) { + this.pos = { x: initX, y: initY }; } getScroll(): Point { diff --git a/test/content/mock/MockSettingRepository.ts b/test/content/mock/MockSettingRepository.ts new file mode 100644 index 0000000..5242713 --- /dev/null +++ b/test/content/mock/MockSettingRepository.ts @@ -0,0 +1,20 @@ +import SettingRepository from "../../../src/content/repositories/SettingRepository"; +import Settings, { + DefaultSetting, +} from "../../../src/shared/settings/Settings"; + +export default class MockSettingRepository implements SettingRepository { + private value: Settings; + + constructor(initValue: Settings = DefaultSetting) { + this.value = initValue; + } + + get(): Settings { + return this.value; + } + + set(setting: Settings): void { + this.value = setting; + } +} diff --git a/test/content/mock/MockURLRepository.ts b/test/content/mock/MockURLRepository.ts new file mode 100644 index 0000000..731a7fb --- /dev/null +++ b/test/content/mock/MockURLRepository.ts @@ -0,0 +1,9 @@ +import URLRepository from "../../../src/content/operators/impls/URLRepository"; + +export default class MockURLRepository implements URLRepository { + constructor(private url: string = "https://example.com/") {} + + getCurrentURL(): string { + return this.url; + } +} |