diff options
Diffstat (limited to 'test/background/repositories')
-rw-r--r-- | test/background/repositories/FindRepository.test.ts | 37 | ||||
-rw-r--r-- | test/background/repositories/Mark.test.ts | 11 | ||||
-rw-r--r-- | test/background/repositories/ReadyFrameRepository.test.ts | 32 |
3 files changed, 74 insertions, 6 deletions
diff --git a/test/background/repositories/FindRepository.test.ts b/test/background/repositories/FindRepository.test.ts new file mode 100644 index 0000000..88d5e71 --- /dev/null +++ b/test/background/repositories/FindRepository.test.ts @@ -0,0 +1,37 @@ +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()).toBeUndefined; + + await sut.setGlobalKeyword("Hello, world"); + + const keyword = await sut.getGlobalKeyword(); + expect(keyword).toEqual("Hello, world"); + }); + }); + + describe("local state", () => { + it("get and set a keyword", async () => { + expect(await sut.getLocalState(10)).toBeUndefined; + + await sut.setLocalState(10, { + keyword: "Hello, world", + frameId: 11, + }); + + const state = await sut.getLocalState(10); + expect(state?.keyword).toEqual("Hello, world"); + expect(state?.frameId).toEqual(11); + + expect(await sut.getLocalState(20)).toBeUndefined; + }); + }); +}); diff --git a/test/background/repositories/Mark.test.ts b/test/background/repositories/Mark.test.ts index 3b054e5..bdee3b7 100644 --- a/test/background/repositories/Mark.test.ts +++ b/test/background/repositories/Mark.test.ts @@ -1,5 +1,4 @@ import MarkRepository from "../../../src/background/repositories/MarkRepository"; -import { expect } from "chai"; describe("background/repositories/mark", () => { let repository: MarkRepository; @@ -14,12 +13,12 @@ describe("background/repositories/mark", () => { await repository.setMark("A", mark); let got = (await repository.getMark("A"))!; - expect(got.tabId).to.equal(1); - expect(got.url).to.equal("http://example.com"); - expect(got.x).to.equal(10); - expect(got.y).to.equal(30); + expect(got.tabId).toEqual(1); + expect(got.url).toEqual("http://example.com"); + expect(got.x).toEqual(10); + expect(got.y).toEqual(30); got = (await repository.getMark("B"))!; - expect(got).to.be.undefined; + expect(got).toBeUndefined; }); }); diff --git a/test/background/repositories/ReadyFrameRepository.test.ts b/test/background/repositories/ReadyFrameRepository.test.ts new file mode 100644 index 0000000..fb4d34a --- /dev/null +++ b/test/background/repositories/ReadyFrameRepository.test.ts @@ -0,0 +1,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; + }); +}); |