aboutsummaryrefslogtreecommitdiff
path: root/test/background/operators/impls/NavigateOperatorFactoryChain.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/background/operators/impls/NavigateOperatorFactoryChain.test.ts')
-rw-r--r--test/background/operators/impls/NavigateOperatorFactoryChain.test.ts56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/background/operators/impls/NavigateOperatorFactoryChain.test.ts b/test/background/operators/impls/NavigateOperatorFactoryChain.test.ts
new file mode 100644
index 0000000..dfb5654
--- /dev/null
+++ b/test/background/operators/impls/NavigateOperatorFactoryChain.test.ts
@@ -0,0 +1,56 @@
+import "reflect-metadata";
+import { expect } from "chai";
+import NavigateOperatorFactoryChain from "../../../../src/background/operators/impls/NavigateOperatorFactoryChain";
+import MockTabPresenter from "../../mock/MockTabPresenter";
+import MockNavigateClient from "../../mock/MockNavigateClient";
+import MockBrowserSettingRepository from "../../mock/MockBrowserSettingRepository";
+import NavigateHistoryPrevOperator from "../../../../src/background/operators/impls/NavigateHistoryPrevOperator";
+import NavigateHistoryNextOperator from "../../../../src/background/operators/impls/NavigateHistoryNextOperator";
+import NavigateLinkPrevOperator from "../../../../src/background/operators/impls/NavigateLinkPrevOperator";
+import NavigateLinkNextOperator from "../../../../src/background/operators/impls/NavigateLinkNextOperator";
+import NavigateParentOperator from "../../../../src/background/operators/impls/NavigateParentOperator";
+import NavigateRootOperator from "../../../../src/background/operators/impls/NavigateRootOperator";
+import OpenHomeOperator from "../../../../src/background/operators/impls/OpenHomeOperator";
+import OpenSourceOperator from "../../../../src/background/operators/impls/OpenSourceOperator";
+import * as operations from "../../../../src/shared/operations";
+
+describe("NavigateOperatorFactoryChain", () => {
+ describe("#create", () => {
+ it("returns a operator for the operation", async () => {
+ const tabPresenter = new MockTabPresenter();
+ const navigateClient = new MockNavigateClient();
+ const browserSettingRepository = new MockBrowserSettingRepository([]);
+ const sut = new NavigateOperatorFactoryChain(
+ tabPresenter,
+ navigateClient,
+ browserSettingRepository
+ );
+
+ expect(
+ sut.create({ type: operations.NAVIGATE_HISTORY_PREV })
+ ).to.be.instanceOf(NavigateHistoryPrevOperator);
+ expect(
+ sut.create({ type: operations.NAVIGATE_HISTORY_NEXT })
+ ).to.be.instanceOf(NavigateHistoryNextOperator);
+ expect(
+ sut.create({ type: operations.NAVIGATE_LINK_PREV })
+ ).to.be.instanceOf(NavigateLinkPrevOperator);
+ expect(
+ sut.create({ type: operations.NAVIGATE_LINK_NEXT })
+ ).to.be.instanceOf(NavigateLinkNextOperator);
+ expect(sut.create({ type: operations.NAVIGATE_PARENT })).to.be.instanceOf(
+ NavigateParentOperator
+ );
+ expect(sut.create({ type: operations.NAVIGATE_ROOT })).to.be.instanceOf(
+ NavigateRootOperator
+ );
+ expect(sut.create({ type: operations.PAGE_SOURCE })).to.be.instanceOf(
+ OpenSourceOperator
+ );
+ expect(
+ sut.create({ type: operations.PAGE_HOME, newTab: false })
+ ).to.be.instanceOf(OpenHomeOperator);
+ expect(sut.create({ type: operations.CANCEL })).to.be.null;
+ });
+ });
+});