aboutsummaryrefslogtreecommitdiff
path: root/test/background/operators/impls/TogglePinnedTabOperator.test.ts
blob: fbd6c3968b5bd3d9a55b3f0d2294271b22b95fc3 (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
import TogglePinnedTabOperator from "../../../../src/background/operators/impls/TogglePinnedTabOperator";
import MockTabPresenter from "../../mock/MockTabPresenter";

describe("TogglePinnedTabOperator", () => {
  describe("#run", () => {
    it("toggle pinned to the current tab", async () => {
      const tabPresenter = new MockTabPresenter();
      await tabPresenter.create("https://example.com/", {
        active: true,
        pinned: false,
      });
      await tabPresenter.create("https://example.com/", {
        active: false,
        pinned: false,
      });
      const sut = new TogglePinnedTabOperator(tabPresenter);

      await sut.run();
      expect((await tabPresenter.getAll()).map((t) => t.pinned)).toEqual([
        true,
        false,
      ]);

      await sut.run();
      expect((await tabPresenter.getAll()).map((t) => t.pinned)).toEqual([
        false,
        false,
      ]);
    });
  });
});