diff options
| author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-09-23 23:23:55 +0900 | 
|---|---|---|
| committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-09-25 15:53:36 +0900 | 
| commit | b72728bdabf140c77f165b35813595dcaa060eea (patch) | |
| tree | 774dc608f28101ac4a0ecce02e458e421b94dcdc /test/background/operators/impls | |
| parent | 01242a2f0d174b4bf8b51fd5627edced465757e9 (diff) | |
Create find targets by port connections
Diffstat (limited to 'test/background/operators/impls')
| -rw-r--r-- | test/background/operators/impls/FindNextOperator.test.ts | 24 | ||||
| -rw-r--r-- | test/background/operators/impls/FindPrevOperator.test.ts | 24 | 
2 files changed, 22 insertions, 26 deletions
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();  | 
