aboutsummaryrefslogtreecommitdiff
path: root/test/background/operators/impls/TabOperatorFactoryChain.test.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-12-10 12:52:17 +0000
committerGitHub <noreply@github.com>2020-12-10 12:52:17 +0000
commit5a0444d7bb7eae27fdca5c2be8fc3ec6c36d53bd (patch)
tree46d70e19f9720d237f4423c1debfcacdd088ce0b /test/background/operators/impls/TabOperatorFactoryChain.test.ts
parenta3c34a309c4b1421eb4914c3fbeba327a5400021 (diff)
parentd2fb674566393d9a8b88d71dba9f5081786b118c (diff)
Merge pull request #917 from ueokande/operation-as-a-operator
refactor: Make each operation as an operator
Diffstat (limited to 'test/background/operators/impls/TabOperatorFactoryChain.test.ts')
-rw-r--r--test/background/operators/impls/TabOperatorFactoryChain.test.ts71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/background/operators/impls/TabOperatorFactoryChain.test.ts b/test/background/operators/impls/TabOperatorFactoryChain.test.ts
new file mode 100644
index 0000000..7ab5de0
--- /dev/null
+++ b/test/background/operators/impls/TabOperatorFactoryChain.test.ts
@@ -0,0 +1,71 @@
+import "reflect-metadata";
+import { expect } from "chai";
+import TabOperatorFactoryChain from "../../../../src/background/operators/impls/TabOperatorFactoryChain";
+import MockTabPresenter from "../../mock/MockTabPresenter";
+import DuplicateTabOperator from "../../../../src/background/operators/impls/DuplicateTabOperator";
+import TogglePinnedTabOperator from "../../../../src/background/operators/impls/TogglePinnedTabOperator";
+import UnpinTabOperator from "../../../../src/background/operators/impls/UnpinTabOperator";
+import PinTabOperator from "../../../../src/background/operators/impls/PinTabOperator";
+import ReloadTabOperator from "../../../../src/background/operators/impls/ReloadTabOperator";
+import SelectPreviousSelectedTabOperator from "../../../../src/background/operators/impls/SelectPreviousSelectedTabOperator";
+import SelectLastTabOperator from "../../../../src/background/operators/impls/SelectLastTabOperator";
+import SelectFirstTabOperator from "../../../../src/background/operators/impls/SelectFirstTabOperator";
+import SelectTabNextOperator from "../../../../src/background/operators/impls/SelectTabNextOperator";
+import SelectTabPrevOperator from "../../../../src/background/operators/impls/SelectTabPrevOperator";
+import ReopenTabOperator from "../../../../src/background/operators/impls/ReopenTabOperator";
+import CloseTabOperator from "../../../../src/background/operators/impls/CloseTabOperator";
+import CloseTabRightOperator from "../../../../src/background/operators/impls/CloseTabRightOperator";
+import * as operations from "../../../../src/shared/operations";
+
+describe("TabOperatorFactoryChain", () => {
+ describe("#create", () => {
+ it("returns a operator for the operation", async () => {
+ const tabPresenter = new MockTabPresenter();
+ const sut = new TabOperatorFactoryChain(tabPresenter);
+
+ expect(sut.create({ type: operations.TAB_CLOSE })).to.be.instanceOf(
+ CloseTabOperator
+ );
+ expect(sut.create({ type: operations.TAB_CLOSE_RIGHT })).to.be.instanceOf(
+ CloseTabRightOperator
+ );
+ expect(sut.create({ type: operations.TAB_CLOSE_FORCE })).to.be.instanceOf(
+ CloseTabOperator
+ );
+ expect(sut.create({ type: operations.TAB_REOPEN })).to.be.instanceOf(
+ ReopenTabOperator
+ );
+ expect(sut.create({ type: operations.TAB_PREV })).to.be.instanceOf(
+ SelectTabPrevOperator
+ );
+ expect(sut.create({ type: operations.TAB_NEXT })).to.be.instanceOf(
+ SelectTabNextOperator
+ );
+ expect(sut.create({ type: operations.TAB_FIRST })).to.be.instanceOf(
+ SelectFirstTabOperator
+ );
+ expect(
+ sut.create({ type: operations.TAB_LAST, newTab: false })
+ ).to.be.instanceOf(SelectLastTabOperator);
+ expect(
+ sut.create({ type: operations.TAB_PREV_SEL, newTab: false })
+ ).to.be.instanceOf(SelectPreviousSelectedTabOperator);
+ expect(
+ sut.create({ type: operations.TAB_RELOAD, cache: false })
+ ).to.be.instanceOf(ReloadTabOperator);
+ expect(sut.create({ type: operations.TAB_PIN })).to.be.instanceOf(
+ PinTabOperator
+ );
+ expect(sut.create({ type: operations.TAB_UNPIN })).to.be.instanceOf(
+ UnpinTabOperator
+ );
+ expect(
+ sut.create({ type: operations.TAB_TOGGLE_PINNED })
+ ).to.be.instanceOf(TogglePinnedTabOperator);
+ expect(sut.create({ type: operations.TAB_DUPLICATE })).to.be.instanceOf(
+ DuplicateTabOperator
+ );
+ expect(sut.create({ type: operations.CANCEL })).to.be.null;
+ });
+ });
+});