aboutsummaryrefslogtreecommitdiff
path: root/test/background/repositories/ReadyFrameRepository.test.ts
blob: fb4d34a20f5e38a7428ad739d29924336d91c403 (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
import { ReadyFrameRepositoryImpl } from "../../../src/background/repositories/ReadyFrameRepository";

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

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

  it("get and set a keyword", async () => {
    expect(await sut.getFrameIds(1)).toBeUndefined;

    await sut.addFrameId(1, 10);
    await sut.addFrameId(1, 12);
    await sut.addFrameId(1, 11);
    await sut.addFrameId(2, 20);
    await sut.addFrameId(2, 21);
    await sut.addFrameId(2, 21);

    expect(await sut.getFrameIds(1)).toEqual([10, 11, 12]);
    expect(await sut.getFrameIds(2)).toEqual([20, 21]);

    await sut.removeFrameId(2, 21);
    expect(await sut.getFrameIds(2)).toEqual([20, 21]);

    await sut.removeFrameId(2, 21);
    expect(await sut.getFrameIds(2)).toEqual([20]);

    await sut.removeFrameId(2, 20);
    expect(await sut.getFrameIds(2)).toBeUndefined;
  });
});