aboutsummaryrefslogtreecommitdiff
path: root/test/background/operators/impls/TabOperatorFactoryChain.test.ts
blob: 57e63217f289bd6ec7057c826049831ff0bdffdb (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import "reflect-metadata";
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 })).toBeInstanceOf(
        CloseTabOperator
      );
      expect(sut.create({ type: operations.TAB_CLOSE_RIGHT })).toBeInstanceOf(
        CloseTabRightOperator
      );
      expect(sut.create({ type: operations.TAB_CLOSE_FORCE })).toBeInstanceOf(
        CloseTabOperator
      );
      expect(sut.create({ type: operations.TAB_REOPEN })).toBeInstanceOf(
        ReopenTabOperator
      );
      expect(sut.create({ type: operations.TAB_PREV })).toBeInstanceOf(
        SelectTabPrevOperator
      );
      expect(sut.create({ type: operations.TAB_NEXT })).toBeInstanceOf(
        SelectTabNextOperator
      );
      expect(sut.create({ type: operations.TAB_FIRST })).toBeInstanceOf(
        SelectFirstTabOperator
      );
      expect(sut.create({ type: operations.TAB_LAST })).toBeInstanceOf(
        SelectLastTabOperator
      );
      expect(sut.create({ type: operations.TAB_PREV_SEL })).toBeInstanceOf(
        SelectPreviousSelectedTabOperator
      );
      expect(
        sut.create({ type: operations.TAB_RELOAD, cache: false })
      ).toBeInstanceOf(ReloadTabOperator);
      expect(sut.create({ type: operations.TAB_PIN })).toBeInstanceOf(
        PinTabOperator
      );
      expect(sut.create({ type: operations.TAB_UNPIN })).toBeInstanceOf(
        UnpinTabOperator
      );
      expect(sut.create({ type: operations.TAB_TOGGLE_PINNED })).toBeInstanceOf(
        TogglePinnedTabOperator
      );
      expect(sut.create({ type: operations.TAB_DUPLICATE })).toBeInstanceOf(
        DuplicateTabOperator
      );
      expect(sut.create({ type: operations.CANCEL })).toBeNull;
    });
  });
});