aboutsummaryrefslogtreecommitdiff
path: root/test/background/repositories/FindRepository.test.ts
blob: a08dc6de4474685eef143a1f1d93beca18c09390 (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
import { expect } from "chai";
import { FindRepositoryImpl } from "../../../src/background/repositories/FindRepository";

describe("background/repositories/FindRepositoryImpl", () => {
  let sut: FindRepositoryImpl;

  beforeEach(() => {
    sut = new FindRepositoryImpl();
  });

  describe("global keyword", () => {
    it("get and set a keyword", async () => {
      expect(await sut.getGlobalKeyword()).to.be.undefined;

      await sut.setGlobalKeyword("Hello, world");

      const keyword = await sut.getGlobalKeyword();
      expect(keyword).to.equal("Hello, world");
    });
  });

  describe("local state", () => {
    it("get and set a keyword", async () => {
      expect(await sut.getLocalState(10)).to.be.undefined;

      await sut.setLocalState(10, {
        keyword: "Hello, world",
        frameIds: [20, 21],
        framePos: 0,
      });

      const state = await sut.getLocalState(10);
      expect(state?.keyword).to.equal("Hello, world");

      expect(await sut.getLocalState(20)).to.be.undefined;
    });
  });
});