aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/background/mock/MockReadyFrameRepository.ts4
-rw-r--r--test/background/operators/impls/FindNextOperator.test.ts24
-rw-r--r--test/background/operators/impls/FindPrevOperator.test.ts24
-rw-r--r--test/background/repositories/FindRepository.test.ts4
-rw-r--r--test/background/usecases/StartFindUseCase.test.ts8
5 files changed, 32 insertions, 32 deletions
diff --git a/test/background/mock/MockReadyFrameRepository.ts b/test/background/mock/MockReadyFrameRepository.ts
index 63b7cf4..a95b2e1 100644
--- a/test/background/mock/MockReadyFrameRepository.ts
+++ b/test/background/mock/MockReadyFrameRepository.ts
@@ -9,6 +9,10 @@ export default class MockReadyFrameRepository implements ReadyFrameRepository {
throw new Error("not implemented");
}
+ removeFrameId(_tabId: number, _frameId: number): Promise<void> {
+ throw new Error("not implemented");
+ }
+
getFrameIds(_tabId: number): Promise<number[] | undefined> {
throw new Error("not implemented");
}
diff --git a/test/background/operators/impls/FindNextOperator.test.ts b/test/background/operators/impls/FindNextOperator.test.ts
index b5088df..7509ef4 100644
--- a/test/background/operators/impls/FindNextOperator.test.ts
+++ b/test/background/operators/impls/FindNextOperator.test.ts
@@ -32,6 +32,10 @@ describe("FindNextOperator", () => {
active: true,
});
currentTabId = currentTab.id!;
+
+ sinon
+ .stub(frameRepository, "getFrameIds")
+ .returns(Promise.resolve(frameIds));
});
describe("#run", () => {
@@ -54,8 +58,7 @@ describe("FindNextOperator", () => {
sinon.stub(findRepository, "getLocalState").returns(
Promise.resolve({
keyword,
- frameIds,
- framePos: 1,
+ frameId: 100,
})
);
@@ -68,7 +71,7 @@ describe("FindNextOperator", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { keyword, frameIds, framePos: 1 });
+ .withArgs(currentTabId, { keyword, frameId: 100 });
await sut.run();
@@ -80,8 +83,7 @@ describe("FindNextOperator", () => {
sinon.stub(findRepository, "getLocalState").returns(
Promise.resolve({
keyword,
- frameIds,
- framePos: 1,
+ frameId: 100,
})
);
@@ -102,7 +104,7 @@ describe("FindNextOperator", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { keyword, frameIds, framePos: 2 });
+ .withArgs(currentTabId, { keyword, frameId: 101 });
await sut.run();
@@ -114,8 +116,7 @@ describe("FindNextOperator", () => {
sinon.stub(findRepository, "getLocalState").returns(
Promise.resolve({
keyword,
- frameIds,
- framePos: 2,
+ frameId: 101,
})
);
@@ -136,7 +137,7 @@ describe("FindNextOperator", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { keyword, frameIds, framePos: 0 });
+ .withArgs(currentTabId, { keyword, frameId: 0 });
await sut.run();
@@ -151,9 +152,6 @@ describe("FindNextOperator", () => {
sinon
.stub(findRepository, "getGlobalKeyword")
.returns(Promise.resolve(keyword));
- sinon
- .stub(frameRepository, "getFrameIds")
- .returns(Promise.resolve(frameIds));
sinon.stub(consoleClient, "showInfo").returns(Promise.resolve());
const mockFindClient = sinon.mock(findClient);
@@ -168,7 +166,7 @@ describe("FindNextOperator", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { keyword, frameIds, framePos: 0 });
+ .withArgs(currentTabId, { keyword, frameId: 0 });
await sut.run();
diff --git a/test/background/operators/impls/FindPrevOperator.test.ts b/test/background/operators/impls/FindPrevOperator.test.ts
index 296f0dd..090f815 100644
--- a/test/background/operators/impls/FindPrevOperator.test.ts
+++ b/test/background/operators/impls/FindPrevOperator.test.ts
@@ -32,6 +32,10 @@ describe("FindPrevOperator", () => {
active: true,
});
currentTabId = currentTab.id!;
+
+ sinon
+ .stub(frameRepository, "getFrameIds")
+ .returns(Promise.resolve(frameIds.slice(0)));
});
describe("#run", () => {
@@ -54,8 +58,7 @@ describe("FindPrevOperator", () => {
sinon.stub(findRepository, "getLocalState").returns(
Promise.resolve({
keyword,
- frameIds,
- framePos: 1,
+ frameId: 100,
})
);
@@ -68,7 +71,7 @@ describe("FindPrevOperator", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { keyword, frameIds, framePos: 1 });
+ .withArgs(currentTabId, { keyword, frameId: 100 });
await sut.run();
@@ -80,8 +83,7 @@ describe("FindPrevOperator", () => {
sinon.stub(findRepository, "getLocalState").returns(
Promise.resolve({
keyword,
- frameIds,
- framePos: 1,
+ frameId: 100,
})
);
@@ -102,7 +104,7 @@ describe("FindPrevOperator", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { keyword, frameIds, framePos: 0 });
+ .withArgs(currentTabId, { keyword, frameId: 0 });
await sut.run();
@@ -114,8 +116,7 @@ describe("FindPrevOperator", () => {
sinon.stub(findRepository, "getLocalState").returns(
Promise.resolve({
keyword,
- frameIds,
- framePos: 0,
+ frameId: 0,
})
);
@@ -136,7 +137,7 @@ describe("FindPrevOperator", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { keyword, frameIds, framePos: 2 });
+ .withArgs(currentTabId, { keyword, frameId: 101 });
await sut.run();
@@ -151,9 +152,6 @@ describe("FindPrevOperator", () => {
sinon
.stub(findRepository, "getGlobalKeyword")
.returns(Promise.resolve(keyword));
- sinon
- .stub(frameRepository, "getFrameIds")
- .returns(Promise.resolve(frameIds));
sinon.stub(consoleClient, "showInfo").returns(Promise.resolve());
const mockFindClient = sinon.mock(findClient);
@@ -168,7 +166,7 @@ describe("FindPrevOperator", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { keyword, frameIds, framePos: 2 });
+ .withArgs(currentTabId, { keyword, frameId: 101 });
await sut.run();
diff --git a/test/background/repositories/FindRepository.test.ts b/test/background/repositories/FindRepository.test.ts
index a08dc6d..d8c9506 100644
--- a/test/background/repositories/FindRepository.test.ts
+++ b/test/background/repositories/FindRepository.test.ts
@@ -25,12 +25,12 @@ describe("background/repositories/FindRepositoryImpl", () => {
await sut.setLocalState(10, {
keyword: "Hello, world",
- frameIds: [20, 21],
- framePos: 0,
+ frameId: 11,
});
const state = await sut.getLocalState(10);
expect(state?.keyword).to.equal("Hello, world");
+ expect(state?.frameId).to.equal(11);
expect(await sut.getLocalState(20)).to.be.undefined;
});
diff --git a/test/background/usecases/StartFindUseCase.test.ts b/test/background/usecases/StartFindUseCase.test.ts
index 99ab508..24e1fdc 100644
--- a/test/background/usecases/StartFindUseCase.test.ts
+++ b/test/background/usecases/StartFindUseCase.test.ts
@@ -46,7 +46,7 @@ describe("StartFindUseCase", () => {
const mockFindRepository = sinon.mock(findRepository);
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { frameIds, framePos: 1, keyword });
+ .withArgs(currentTabId, { keyword, frameId: 100 });
const mockConsoleClient = sinon.mock(consoleClient);
mockConsoleClient
.expects("showInfo")
@@ -76,10 +76,10 @@ describe("StartFindUseCase", () => {
mockFindRepository
.expects("getLocalState")
.withArgs(currentTabId)
- .returns(Promise.resolve({ keyword, frameIds, framePos: 0 }));
+ .returns(Promise.resolve({ keyword, frameId: 0 }));
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { frameIds, framePos: 1, keyword });
+ .withArgs(currentTabId, { keyword, frameId: 100 });
const mockConsoleClient = sinon.mock(consoleClient);
mockConsoleClient
.expects("showInfo")
@@ -115,7 +115,7 @@ describe("StartFindUseCase", () => {
.returns(Promise.resolve(keyword));
mockFindRepository
.expects("setLocalState")
- .withArgs(currentTabId, { frameIds, framePos: 1, keyword });
+ .withArgs(currentTabId, { keyword, frameId: 100 });
const mockConsoleClient = sinon.mock(consoleClient);
mockConsoleClient
.expects("showInfo")