aboutsummaryrefslogtreecommitdiff
path: root/test/background/operators/impls/InternalOperatorFactoryChain.test.ts
blob: c13ebaf8fa0fd832402f0909e747b3a372479492 (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
import "reflect-metadata";
import InternalOperatorFactoryChain from "../../../../src/background/operators/impls/InternalOperatorFactoryChain";
import MockWindowPresenter from "../../mock/MockWindowPresenter";
import MockTabPresenter from "../../mock/MockTabPresenter";
import MockConsoleClient from "../../mock/MockConsoleClient";
import CancelOperator from "../../../../src/background/operators/impls/CancelOperator";
import InternalOpenURLOperator from "../../../../src/background/operators/impls/InternalOpenURLOperator";
import * as operations from "../../../../src/shared/operations";

describe("InternalOperatorFactoryChain", () => {
  describe("#create", () => {
    it("returns a operator for the operation", async () => {
      const windowPresenter = new MockWindowPresenter();
      const tabPresenter = new MockTabPresenter();
      const consoleClient = new MockConsoleClient();
      const sut = new InternalOperatorFactoryChain(
        windowPresenter,
        tabPresenter,
        consoleClient
      );

      expect(sut.create({ type: operations.CANCEL })).toBeInstanceOf(
        CancelOperator
      );
      expect(
        sut.create({
          type: operations.INTERNAL_OPEN_URL,
          url: "https://example.com",
          newTab: false,
          newWindow: false,
        })
      ).toBeInstanceOf(InternalOpenURLOperator);
      expect(sut.create({ type: operations.COMMAND_SHOW })).toBeNull;
    });
  });
});