diff options
Diffstat (limited to 'test/background/operators/impls')
43 files changed, 308 insertions, 437 deletions
diff --git a/test/background/operators/impls/CancelOperator.test.ts b/test/background/operators/impls/CancelOperator.test.ts index 915becf..a723f6f 100644 --- a/test/background/operators/impls/CancelOperator.test.ts +++ b/test/background/operators/impls/CancelOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import CancelOperator from "../../../../src/background/operators/impls/CancelOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -10,15 +9,14 @@ describe("CancelOperator", () => { const currenTab = await tabPresenter.create("https://example.com/"); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("hide") - .withArgs(currenTab?.id); + const spy = jest + .spyOn(consoleClient, "hide") + .mockResolvedValueOnce(undefined); const sut = new CancelOperator(tabPresenter, consoleClient); await sut.run(); - mock.verify(); + expect(spy).toBeCalledWith(currenTab?.id); }); }); }); diff --git a/test/background/operators/impls/CloseTabOperator.test.ts b/test/background/operators/impls/CloseTabOperator.test.ts index ba9cbfe..f72e118 100644 --- a/test/background/operators/impls/CloseTabOperator.test.ts +++ b/test/background/operators/impls/CloseTabOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import CloseTabOperator from "../../../../src/background/operators/impls/CloseTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -14,7 +13,7 @@ describe("CloseTabOperator", () => { await sut.run(); const tabs = await tabPresenter.getAll(); - expect(tabs.map((t) => t.url)).to.deep.equal([ + expect(tabs.map((t) => t.url)).toEqual([ "https://example.com/1", "https://example.com/3", ]); @@ -39,7 +38,7 @@ describe("CloseTabOperator", () => { await sut.run(); const tabs = await tabPresenter.getAll(); - expect(tabs.map((t) => t.url)).to.deep.equal([ + expect(tabs.map((t) => t.url)).toEqual([ "https://example.com/1", "https://example.com/3", ]); @@ -55,7 +54,7 @@ describe("CloseTabOperator", () => { await sut.run(); const tab = await tabPresenter.getCurrent(); - expect(tab.url).to.equal("https://example.com/1"); + expect(tab.url).toEqual("https://example.com/1"); }); }); }); diff --git a/test/background/operators/impls/CloseTabRightOperator.test.ts b/test/background/operators/impls/CloseTabRightOperator.test.ts index c2a106c..8e2200e 100644 --- a/test/background/operators/impls/CloseTabRightOperator.test.ts +++ b/test/background/operators/impls/CloseTabRightOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import MockTabPresenter from "../../mock/MockTabPresenter"; import CloseTabRightOperator from "../../../../src/background/operators/impls/CloseTabRightOperator"; @@ -15,7 +14,7 @@ describe("CloseTabRightOperator", () => { await sut.run(); const tabs = await tabPresenter.getAll(); - expect(tabs.map((t) => t.url)).to.deep.equal([ + expect(tabs.map((t) => t.url)).toEqual([ "https://example.com/1", "https://example.com/2", ]); diff --git a/test/background/operators/impls/CommandOperatorFactoryChain.test.ts b/test/background/operators/impls/CommandOperatorFactoryChain.test.ts index e481c5a..ce8676a 100644 --- a/test/background/operators/impls/CommandOperatorFactoryChain.test.ts +++ b/test/background/operators/impls/CommandOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import "reflect-metadata"; -import { expect } from "chai"; import CommandOperatorFactoryChain from "../../../../src/background/operators/impls/CommandOperatorFactoryChain"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -18,25 +17,25 @@ describe("CommandOperatorFactoryChain", () => { const consoleClient = new MockConsoleClient(); const sut = new CommandOperatorFactoryChain(tabPresenter, consoleClient); - expect(sut.create({ type: operations.COMMAND_SHOW })).to.be.instanceOf( + expect(sut.create({ type: operations.COMMAND_SHOW })).toBeInstanceOf( ShowCommandOperator ); expect( sut.create({ type: operations.COMMAND_SHOW_TABOPEN, alter: true }) - ).to.be.instanceOf(ShowTabOpenCommandOperator); + ).toBeInstanceOf(ShowTabOpenCommandOperator); expect( sut.create({ type: operations.COMMAND_SHOW_WINOPEN, alter: true }) - ).to.be.instanceOf(ShowWinOpenCommandOperator); + ).toBeInstanceOf(ShowWinOpenCommandOperator); expect( sut.create({ type: operations.COMMAND_SHOW_BUFFER }) - ).to.be.instanceOf(ShowBufferCommandOperator); + ).toBeInstanceOf(ShowBufferCommandOperator); expect( sut.create({ type: operations.COMMAND_SHOW_ADDBOOKMARK, alter: true }) - ).to.be.instanceOf(ShowAddBookmarkOperator); - expect(sut.create({ type: operations.FIND_START })).to.be.instanceOf( + ).toBeInstanceOf(ShowAddBookmarkOperator); + expect(sut.create({ type: operations.FIND_START })).toBeInstanceOf( StartFindOperator ); - expect(sut.create({ type: operations.CANCEL })).to.be.null; + expect(sut.create({ type: operations.CANCEL })).toBeNull; }); }); }); diff --git a/test/background/operators/impls/DuplicateTabOperator.test.ts b/test/background/operators/impls/DuplicateTabOperator.test.ts index ce2c19d..cbc9e81 100644 --- a/test/background/operators/impls/DuplicateTabOperator.test.ts +++ b/test/background/operators/impls/DuplicateTabOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import DuplicateTabOperator from "../../../../src/background/operators/impls/DuplicateTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -14,7 +13,7 @@ describe("DuplicateTabOperator", () => { await sut.run(); const tabs = await tabPresenter.getAll(); - expect(tabs.map((t) => t.url)).to.deep.equal([ + expect(tabs.map((t) => t.url)).toEqual([ "https://example.com/1", "https://example.com/2", "https://example.com/3", diff --git a/test/background/operators/impls/FindNextOperator.test.ts b/test/background/operators/impls/FindNextOperator.test.ts index 7509ef4..3bb47f0 100644 --- a/test/background/operators/impls/FindNextOperator.test.ts +++ b/test/background/operators/impls/FindNextOperator.test.ts @@ -1,4 +1,3 @@ -import * as sinon from "sinon"; import MockTabPresenter from "../../mock/MockTabPresenter"; import FindNextOperator from "../../../../src/background/operators/impls/FindNextOperator"; import MockFindRepository from "../../mock/MockFindRepository"; @@ -23,155 +22,114 @@ describe("FindNextOperator", () => { frameRepository ); + const findNextSpy = jest.spyOn(findClient, "findNext"); + const clearSelectionSpy = jest.spyOn(findClient, "clearSelection"); + let currentTabId: number; beforeEach(async () => { - sinon.restore(); - const currentTab = await tabPresenter.create("https://example.com/", { active: true, }); currentTabId = currentTab.id!; - sinon - .stub(frameRepository, "getFrameIds") - .returns(Promise.resolve(frameIds)); + findNextSpy.mockClear(); + clearSelectionSpy.mockClear().mockReturnValue(Promise.resolve()); + jest.spyOn(frameRepository, "getFrameIds").mockResolvedValue(frameIds); }); describe("#run", () => { it("shows errors if no previous keywords", async () => { - sinon - .stub(findRepository, "getLocalState") - .returns(Promise.resolve(undefined)); - - const mock = sinon.mock(consoleClient); - mock - .expects("showError") - .withArgs(currentTabId, "No previous search keywords"); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue(undefined); + const showErrorSpy = jest + .spyOn(consoleClient, "showError") + .mockReturnValue(Promise.resolve()); await sut.run(); - mock.verify(); + expect(showErrorSpy).toBeCalledWith( + currentTabId, + "No previous search keywords" + ); }); it("continues a search on the same frame", async () => { - sinon.stub(findRepository, "getLocalState").returns( - Promise.resolve({ - keyword, - frameId: 100, - }) - ); - - const mockFindClient = sinon.mock(findClient); - mockFindClient - .expects("findNext") - .withArgs(currentTabId, 100, keyword) - .returns(Promise.resolve(true)); - - const mockFindRepository = sinon.mock(findRepository); - mockFindRepository - .expects("setLocalState") - .withArgs(currentTabId, { keyword, frameId: 100 }); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue({ + keyword, + frameId: 100, + }); + findNextSpy.mockResolvedValue(true); + const setLocalStateSpy = jest.spyOn(findRepository, "setLocalState"); await sut.run(); - mockFindRepository.verify(); - mockFindClient.verify(); + expect(findNextSpy).toBeCalledWith(currentTabId, 100, keyword); + expect(setLocalStateSpy).toBeCalledWith(currentTabId, { + keyword, + frameId: 100, + }); }); it("continues a search on next frame", async () => { - sinon.stub(findRepository, "getLocalState").returns( - Promise.resolve({ - keyword, - frameId: 100, - }) - ); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue({ + keyword, + frameId: 100, + }); - const mockFindClient = sinon.mock(findClient); - mockFindClient - .expects("findNext") - .withArgs(currentTabId, 100, keyword) - .returns(Promise.resolve(false)); - mockFindClient - .expects("clearSelection") - .withArgs(currentTabId, 100) - .returns(Promise.resolve()); - mockFindClient - .expects("findNext") - .withArgs(currentTabId, 101, keyword) - .returns(Promise.resolve(true)); - - const mockFindRepository = sinon.mock(findRepository); - mockFindRepository - .expects("setLocalState") - .withArgs(currentTabId, { keyword, frameId: 101 }); + findNextSpy.mockResolvedValueOnce(false).mockResolvedValueOnce(true); + const setLocalStateSpy = jest.spyOn(findRepository, "setLocalState"); await sut.run(); - mockFindRepository.verify(); - mockFindClient.verify(); + expect(findNextSpy).toBeCalledTimes(2); + expect(findNextSpy.mock.calls[0][1]).toEqual(100); + expect(findNextSpy.mock.calls[1][1]).toEqual(101); + expect(clearSelectionSpy).toBeCalledWith(currentTabId, 100); + expect(setLocalStateSpy).toBeCalledWith(currentTabId, { + keyword, + frameId: 101, + }); }); it("exercise a wrap-search", async () => { - sinon.stub(findRepository, "getLocalState").returns( - Promise.resolve({ - keyword, - frameId: 101, - }) - ); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue({ + keyword, + frameId: 101, + }); - const mockFindClient = sinon.mock(findClient); - mockFindClient - .expects("findNext") - .withArgs(currentTabId, 101, keyword) - .returns(Promise.resolve(false)); - mockFindClient - .expects("clearSelection") - .withArgs(currentTabId, 101) - .returns(Promise.resolve()); - mockFindClient - .expects("findNext") - .withArgs(currentTabId, 0, keyword) - .returns(Promise.resolve(true)); - - const mockFindRepository = sinon.mock(findRepository); - mockFindRepository - .expects("setLocalState") - .withArgs(currentTabId, { keyword, frameId: 0 }); + findNextSpy.mockResolvedValueOnce(false).mockResolvedValueOnce(true); + const setLocalStateSpy = jest.spyOn(findRepository, "setLocalState"); await sut.run(); - mockFindRepository.verify(); - mockFindClient.verify(); + expect(findNextSpy).toBeCalledTimes(2); + expect(findNextSpy.mock.calls[0][1]).toEqual(101); + expect(findNextSpy.mock.calls[1][1]).toEqual(0); + expect(clearSelectionSpy).toBeCalledWith(currentTabId, 101); + expect(setLocalStateSpy).toBeCalledWith(currentTabId, { + keyword, + frameId: 0, + }); }); it("starts a search with last keywords", async () => { - sinon - .stub(findRepository, "getLocalState") - .returns(Promise.resolve(undefined)); - sinon - .stub(findRepository, "getGlobalKeyword") - .returns(Promise.resolve(keyword)); - sinon.stub(consoleClient, "showInfo").returns(Promise.resolve()); - - const mockFindClient = sinon.mock(findClient); - mockFindClient.expects("clearSelection").withArgs(currentTabId, 0); - mockFindClient.expects("clearSelection").withArgs(currentTabId, 100); - mockFindClient.expects("clearSelection").withArgs(currentTabId, 101); - mockFindClient - .expects("findNext") - .withArgs(currentTabId, 0, keyword) - .returns(Promise.resolve(true)); - - const mockFindRepository = sinon.mock(findRepository); - mockFindRepository - .expects("setLocalState") - .withArgs(currentTabId, { keyword, frameId: 0 }); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue(undefined); + jest.spyOn(findRepository, "getGlobalKeyword").mockResolvedValue(keyword); + jest.spyOn(consoleClient, "showInfo").mockReturnValue(Promise.resolve()); + + const setLocalStateSpy = jest.spyOn(findRepository, "setLocalState"); await sut.run(); - mockFindRepository.verify(); - mockFindClient.verify(); + expect(clearSelectionSpy).toBeCalledTimes(3); + expect(clearSelectionSpy.mock.calls[0][1]).toEqual(0); + expect(clearSelectionSpy.mock.calls[1][1]).toEqual(100); + expect(clearSelectionSpy.mock.calls[2][1]).toEqual(101); + expect(findNextSpy).toBeCalledWith(currentTabId, 0, keyword); + expect(setLocalStateSpy).toBeCalledWith(currentTabId, { + keyword, + frameId: 0, + }); }); }); }); diff --git a/test/background/operators/impls/FindOperatorFactoryChain.ts b/test/background/operators/impls/FindOperatorFactoryChain.ts index 0fd234f..6b190ed 100644 --- a/test/background/operators/impls/FindOperatorFactoryChain.ts +++ b/test/background/operators/impls/FindOperatorFactoryChain.ts @@ -1,5 +1,4 @@ import "reflect-metadata"; -import { expect } from "chai"; import TabOperatorFactoryChain from "../../../../src/background/operators/impls/TabOperatorFactoryChain"; import MockTabPresenter from "../../mock/MockTabPresenter"; import * as operations from "../../../../src/shared/operations"; @@ -12,10 +11,10 @@ describe("FindOperatorFactoryChain", () => { const tabPresenter = new MockTabPresenter(); const sut = new TabOperatorFactoryChain(tabPresenter); - expect(sut.create({ type: operations.FIND_NEXT })).to.be.instanceOf( + expect(sut.create({ type: operations.FIND_NEXT })).toBeInstanceOf( FindNextOperator ); - expect(sut.create({ type: operations.FIND_PREV })).to.be.instanceOf( + expect(sut.create({ type: operations.FIND_PREV })).toBeInstanceOf( FindPrevOperator ); }); diff --git a/test/background/operators/impls/FindPrevOperator.test.ts b/test/background/operators/impls/FindPrevOperator.test.ts index 090f815..b563076 100644 --- a/test/background/operators/impls/FindPrevOperator.test.ts +++ b/test/background/operators/impls/FindPrevOperator.test.ts @@ -1,4 +1,3 @@ -import * as sinon from "sinon"; import MockTabPresenter from "../../mock/MockTabPresenter"; import FindPrevOperator from "../../../../src/background/operators/impls/FindPrevOperator"; import MockFindRepository from "../../mock/MockFindRepository"; @@ -23,155 +22,113 @@ describe("FindPrevOperator", () => { frameRepository ); + const findPrevSpy = jest.spyOn(findClient, "findPrev"); + const clearSelectionSpy = jest.spyOn(findClient, "clearSelection"); + let currentTabId: number; beforeEach(async () => { - sinon.restore(); - const currentTab = await tabPresenter.create("https://example.com/", { active: true, }); currentTabId = currentTab.id!; - sinon - .stub(frameRepository, "getFrameIds") - .returns(Promise.resolve(frameIds.slice(0))); + findPrevSpy.mockClear(); + clearSelectionSpy.mockClear().mockReturnValue(Promise.resolve()); + jest.spyOn(frameRepository, "getFrameIds").mockResolvedValue(frameIds); }); describe("#run", () => { it("shows errors if no previous keywords", async () => { - sinon - .stub(findRepository, "getLocalState") - .returns(Promise.resolve(undefined)); - - const mock = sinon.mock(consoleClient); - mock - .expects("showError") - .withArgs(currentTabId, "No previous search keywords"); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue(undefined); + const showErrorSpy = jest + .spyOn(consoleClient, "showError") + .mockReturnValue(Promise.resolve()); await sut.run(); - mock.verify(); + expect(showErrorSpy).toBeCalledWith( + currentTabId, + "No previous search keywords" + ); }); it("continues a search on the same frame", async () => { - sinon.stub(findRepository, "getLocalState").returns( - Promise.resolve({ - keyword, - frameId: 100, - }) - ); - - const mockFindClient = sinon.mock(findClient); - mockFindClient - .expects("findPrev") - .withArgs(currentTabId, 100, keyword) - .returns(Promise.resolve(true)); - - const mockFindRepository = sinon.mock(findRepository); - mockFindRepository - .expects("setLocalState") - .withArgs(currentTabId, { keyword, frameId: 100 }); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue({ + keyword, + frameId: 100, + }); + findPrevSpy.mockResolvedValue(true); + const setLocalStateSpy = jest.spyOn(findRepository, "setLocalState"); await sut.run(); - mockFindRepository.verify(); - mockFindClient.verify(); + expect(findPrevSpy).toBeCalledWith(currentTabId, 100, keyword); + expect(setLocalStateSpy).toBeCalledWith(currentTabId, { + keyword, + frameId: 100, + }); }); it("continues a search on next frame", async () => { - sinon.stub(findRepository, "getLocalState").returns( - Promise.resolve({ - keyword, - frameId: 100, - }) - ); - - const mockFindClient = sinon.mock(findClient); - mockFindClient - .expects("findPrev") - .withArgs(currentTabId, 100, keyword) - .returns(Promise.resolve(false)); - mockFindClient - .expects("clearSelection") - .withArgs(currentTabId, 100) - .returns(Promise.resolve()); - mockFindClient - .expects("findPrev") - .withArgs(currentTabId, 0, keyword) - .returns(Promise.resolve(true)); - - const mockFindRepository = sinon.mock(findRepository); - mockFindRepository - .expects("setLocalState") - .withArgs(currentTabId, { keyword, frameId: 0 }); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue({ + keyword, + frameId: 100, + }); + findPrevSpy.mockResolvedValueOnce(false).mockResolvedValueOnce(true); + const setLocalStateSpy = jest.spyOn(findRepository, "setLocalState"); await sut.run(); - mockFindRepository.verify(); - mockFindClient.verify(); + expect(findPrevSpy).toBeCalledTimes(2); + expect(findPrevSpy.mock.calls[0][1]).toEqual(100); + expect(findPrevSpy.mock.calls[1][1]).toEqual(0); + expect(clearSelectionSpy).toBeCalledWith(currentTabId, 100); + expect(setLocalStateSpy).toBeCalledWith(currentTabId, { + keyword, + frameId: 0, + }); }); it("exercise a wrap-search", async () => { - sinon.stub(findRepository, "getLocalState").returns( - Promise.resolve({ - keyword, - frameId: 0, - }) - ); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue({ + keyword, + frameId: 0, + }); - const mockFindClient = sinon.mock(findClient); - mockFindClient - .expects("findPrev") - .withArgs(currentTabId, 0, keyword) - .returns(Promise.resolve(false)); - mockFindClient - .expects("clearSelection") - .withArgs(currentTabId, 0) - .returns(Promise.resolve()); - mockFindClient - .expects("findPrev") - .withArgs(currentTabId, 101, keyword) - .returns(Promise.resolve(true)); - - const mockFindRepository = sinon.mock(findRepository); - mockFindRepository - .expects("setLocalState") - .withArgs(currentTabId, { keyword, frameId: 101 }); + findPrevSpy.mockResolvedValueOnce(false).mockResolvedValueOnce(true); + const setLocalStateSpy = jest.spyOn(findRepository, "setLocalState"); await sut.run(); - mockFindRepository.verify(); - mockFindClient.verify(); + expect(findPrevSpy).toBeCalledTimes(2); + expect(findPrevSpy.mock.calls[0][1]).toEqual(0); + expect(findPrevSpy.mock.calls[1][1]).toEqual(101); + expect(clearSelectionSpy).toBeCalledWith(currentTabId, 0); + expect(setLocalStateSpy).toBeCalledWith(currentTabId, { + keyword, + frameId: 101, + }); }); it("starts a search with last keywords", async () => { - sinon - .stub(findRepository, "getLocalState") - .returns(Promise.resolve(undefined)); - sinon - .stub(findRepository, "getGlobalKeyword") - .returns(Promise.resolve(keyword)); - sinon.stub(consoleClient, "showInfo").returns(Promise.resolve()); - - const mockFindClient = sinon.mock(findClient); - mockFindClient.expects("clearSelection").withArgs(currentTabId, 0); - mockFindClient.expects("clearSelection").withArgs(currentTabId, 100); - mockFindClient.expects("clearSelection").withArgs(currentTabId, 101); - mockFindClient - .expects("findPrev") - .withArgs(currentTabId, 101, keyword) - .returns(Promise.resolve(true)); - - const mockFindRepository = sinon.mock(findRepository); - mockFindRepository - .expects("setLocalState") - .withArgs(currentTabId, { keyword, frameId: 101 }); + jest.spyOn(findRepository, "getLocalState").mockResolvedValue(undefined); + jest.spyOn(findRepository, "getGlobalKeyword").mockResolvedValue(keyword); + jest.spyOn(consoleClient, "showInfo").mockReturnValue(Promise.resolve()); + + const setLocalStateSpy = jest.spyOn(findRepository, "setLocalState"); await sut.run(); - mockFindRepository.verify(); - mockFindClient.verify(); + expect(clearSelectionSpy).toBeCalledTimes(3); + expect(clearSelectionSpy.mock.calls[0][1]).toEqual(101); + expect(clearSelectionSpy.mock.calls[1][1]).toEqual(100); + expect(clearSelectionSpy.mock.calls[2][1]).toEqual(0); + expect(findPrevSpy).toBeCalledWith(currentTabId, 101, keyword); + expect(setLocalStateSpy).toBeCalledWith(currentTabId, { + keyword, + frameId: 101, + }); }); }); }); diff --git a/test/background/operators/impls/InternalOpenURLOperator.test.ts b/test/background/operators/impls/InternalOpenURLOperator.test.ts deleted file mode 100644 index e69de29..0000000 --- a/test/background/operators/impls/InternalOpenURLOperator.test.ts +++ /dev/null diff --git a/test/background/operators/impls/InternalOperatorFactoryChain.test.ts b/test/background/operators/impls/InternalOperatorFactoryChain.test.ts index 09029db..c13ebaf 100644 --- a/test/background/operators/impls/InternalOperatorFactoryChain.test.ts +++ b/test/background/operators/impls/InternalOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import "reflect-metadata"; -import { expect } from "chai"; import InternalOperatorFactoryChain from "../../../../src/background/operators/impls/InternalOperatorFactoryChain"; import MockWindowPresenter from "../../mock/MockWindowPresenter"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -20,7 +19,7 @@ describe("InternalOperatorFactoryChain", () => { consoleClient ); - expect(sut.create({ type: operations.CANCEL })).to.be.instanceOf( + expect(sut.create({ type: operations.CANCEL })).toBeInstanceOf( CancelOperator ); expect( @@ -30,8 +29,8 @@ describe("InternalOperatorFactoryChain", () => { newTab: false, newWindow: false, }) - ).to.be.instanceOf(InternalOpenURLOperator); - expect(sut.create({ type: operations.COMMAND_SHOW })).to.be.null; + ).toBeInstanceOf(InternalOpenURLOperator); + expect(sut.create({ type: operations.COMMAND_SHOW })).toBeNull; }); }); }); diff --git a/test/background/operators/impls/NavigateHistoryNextOperator.test.ts b/test/background/operators/impls/NavigateHistoryNextOperator.test.ts index de8f597..8ea925b 100644 --- a/test/background/operators/impls/NavigateHistoryNextOperator.test.ts +++ b/test/background/operators/impls/NavigateHistoryNextOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import NavigateHistoryNextOperator from "../../../../src/background/operators/impls/NavigateHistoryNextOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockNavigateClient from "../../mock/MockNavigateClient"; @@ -7,10 +6,9 @@ describe("NavigateHistoryNextOperator", () => { describe("#run", () => { it("send a message to navigate next in the history", async () => { const navigateClient = new MockNavigateClient(); - const mock = sinon - .mock(navigateClient) - .expects("historyNext") - .withArgs(1); + const historyNextSpy = jest + .spyOn(navigateClient, "historyNext") + .mockReturnValue(Promise.resolve()); const tabPresenter = new MockTabPresenter(); await tabPresenter.create("https://example.com/1", { active: false }); await tabPresenter.create("https://example.com/2", { active: true }); @@ -19,7 +17,7 @@ describe("NavigateHistoryNextOperator", () => { await sut.run(); - mock.verify(); + expect(historyNextSpy).toBeCalledWith(1); }); }); }); diff --git a/test/background/operators/impls/NavigateHistoryPrevOperator.test.ts b/test/background/operators/impls/NavigateHistoryPrevOperator.test.ts index 6ebe71e..8221a5c 100644 --- a/test/background/operators/impls/NavigateHistoryPrevOperator.test.ts +++ b/test/background/operators/impls/NavigateHistoryPrevOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import NavigateHistoryPrevOperator from "../../../../src/background/operators/impls/NavigateHistoryPrevOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockNavigateClient from "../../mock/MockNavigateClient"; @@ -7,10 +6,9 @@ describe("NavigateHistoryPrevOperator", () => { describe("#run", () => { it("send a message to navigate previous in the history", async () => { const navigateClient = new MockNavigateClient(); - const mock = sinon - .mock(navigateClient) - .expects("historyPrev") - .withArgs(1); + const historyNextSpy = jest + .spyOn(navigateClient, "historyPrev") + .mockReturnValue(Promise.resolve()); const tabPresenter = new MockTabPresenter(); await tabPresenter.create("https://example.com/1", { active: false }); await tabPresenter.create("https://example.com/2", { active: true }); @@ -19,7 +17,7 @@ describe("NavigateHistoryPrevOperator", () => { await sut.run(); - mock.verify(); + expect(historyNextSpy).toBeCalledWith(1); }); }); }); diff --git a/test/background/operators/impls/NavigateLinkNextOperator.test.ts b/test/background/operators/impls/NavigateLinkNextOperator.test.ts index 09c4907..9f19307 100644 --- a/test/background/operators/impls/NavigateLinkNextOperator.test.ts +++ b/test/background/operators/impls/NavigateLinkNextOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import NavigateLinkNextOperator from "../../../../src/background/operators/impls/NavigateLinkNextOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockNavigateClient from "../../mock/MockNavigateClient"; @@ -7,7 +6,9 @@ describe("NavigateLinkNextOperator", () => { describe("#run", () => { it("send a message to navigate next page", async () => { const navigateClient = new MockNavigateClient(); - const mock = sinon.mock(navigateClient).expects("linkNext").withArgs(1); + const linkNextSpy = jest + .spyOn(navigateClient, "linkNext") + .mockReturnValueOnce(Promise.resolve()); const tabPresenter = new MockTabPresenter(); await tabPresenter.create("https://example.com/1", { active: false }); await tabPresenter.create("https://example.com/2", { active: true }); @@ -16,7 +17,7 @@ describe("NavigateLinkNextOperator", () => { await sut.run(); - mock.verify(); + expect(linkNextSpy).toBeCalledWith(1); }); }); }); diff --git a/test/background/operators/impls/NavigateLinkPrevOperator.test.ts b/test/background/operators/impls/NavigateLinkPrevOperator.test.ts index 6b7f791..37999bd 100644 --- a/test/background/operators/impls/NavigateLinkPrevOperator.test.ts +++ b/test/background/operators/impls/NavigateLinkPrevOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import NavigateLinkPrevOperator from "../../../../src/background/operators/impls/NavigateLinkPrevOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockNavigateClient from "../../mock/MockNavigateClient"; @@ -7,7 +6,9 @@ describe("NavigateLinkPrevOperator", () => { describe("#run", () => { it("send a message to navigate next page", async () => { const navigateClient = new MockNavigateClient(); - const mock = sinon.mock(navigateClient).expects("linkPrev").withArgs(1); + const linkPrevSpy = jest + .spyOn(navigateClient, "linkPrev") + .mockReturnValueOnce(Promise.resolve()); const tabPresenter = new MockTabPresenter(); await tabPresenter.create("https://example.com/1", { active: false }); await tabPresenter.create("https://example.com/2", { active: true }); @@ -16,7 +17,7 @@ describe("NavigateLinkPrevOperator", () => { await sut.run(); - mock.verify(); + expect(linkPrevSpy).toBeCalledWith(1); }); }); }); diff --git a/test/background/operators/impls/NavigateOperatorFactoryChain.test.ts b/test/background/operators/impls/NavigateOperatorFactoryChain.test.ts index dfb5654..ae556f0 100644 --- a/test/background/operators/impls/NavigateOperatorFactoryChain.test.ts +++ b/test/background/operators/impls/NavigateOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import "reflect-metadata"; -import { expect } from "chai"; import NavigateOperatorFactoryChain from "../../../../src/background/operators/impls/NavigateOperatorFactoryChain"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockNavigateClient from "../../mock/MockNavigateClient"; @@ -28,29 +27,29 @@ describe("NavigateOperatorFactoryChain", () => { expect( sut.create({ type: operations.NAVIGATE_HISTORY_PREV }) - ).to.be.instanceOf(NavigateHistoryPrevOperator); + ).toBeInstanceOf(NavigateHistoryPrevOperator); expect( sut.create({ type: operations.NAVIGATE_HISTORY_NEXT }) - ).to.be.instanceOf(NavigateHistoryNextOperator); + ).toBeInstanceOf(NavigateHistoryNextOperator); expect( sut.create({ type: operations.NAVIGATE_LINK_PREV }) - ).to.be.instanceOf(NavigateLinkPrevOperator); + ).toBeInstanceOf(NavigateLinkPrevOperator); expect( sut.create({ type: operations.NAVIGATE_LINK_NEXT }) - ).to.be.instanceOf(NavigateLinkNextOperator); - expect(sut.create({ type: operations.NAVIGATE_PARENT })).to.be.instanceOf( + ).toBeInstanceOf(NavigateLinkNextOperator); + expect(sut.create({ type: operations.NAVIGATE_PARENT })).toBeInstanceOf( NavigateParentOperator ); - expect(sut.create({ type: operations.NAVIGATE_ROOT })).to.be.instanceOf( + expect(sut.create({ type: operations.NAVIGATE_ROOT })).toBeInstanceOf( NavigateRootOperator ); - expect(sut.create({ type: operations.PAGE_SOURCE })).to.be.instanceOf( + expect(sut.create({ type: operations.PAGE_SOURCE })).toBeInstanceOf( OpenSourceOperator ); expect( sut.create({ type: operations.PAGE_HOME, newTab: false }) - ).to.be.instanceOf(OpenHomeOperator); - expect(sut.create({ type: operations.CANCEL })).to.be.null; + ).toBeInstanceOf(OpenHomeOperator); + expect(sut.create({ type: operations.CANCEL })).toBeNull; }); }); }); diff --git a/test/background/operators/impls/NavigateParentOperator.test.ts b/test/background/operators/impls/NavigateParentOperator.test.ts index cc57f17..48c14dd 100644 --- a/test/background/operators/impls/NavigateParentOperator.test.ts +++ b/test/background/operators/impls/NavigateParentOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import MockTabPresenter from "../../mock/MockTabPresenter"; import NavigateParentOperator from "../../../../src/background/operators/impls/NavigateParentOperator"; @@ -14,7 +13,7 @@ describe("NavigateParentOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.be.equal("https://example.com/fruits/yellow/"); + expect(url).toEqual("https://example.com/fruits/yellow/"); }); it("opens a parent directory of the directoryin the URL", async () => { @@ -25,7 +24,7 @@ describe("NavigateParentOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.be.equal("https://example.com/fruits/"); + expect(url).toEqual("https://example.com/fruits/"); }); it("removes a hash in the URL", async () => { @@ -36,7 +35,7 @@ describe("NavigateParentOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.be.equal("https://example.com/fruits/yellow/"); + expect(url).toEqual("https://example.com/fruits/yellow/"); }); it("removes query parameters in the URL", async () => { @@ -47,7 +46,7 @@ describe("NavigateParentOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.be.equal("https://example.com/search"); + expect(url).toEqual("https://example.com/search"); }); }); }); diff --git a/test/background/operators/impls/NavigateRootOperator.test.ts b/test/background/operators/impls/NavigateRootOperator.test.ts index bbe574c..379ce44 100644 --- a/test/background/operators/impls/NavigateRootOperator.test.ts +++ b/test/background/operators/impls/NavigateRootOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import NavigateRootOperator from "../../../../src/background/operators/impls/NavigateRootOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -12,7 +11,7 @@ describe("NavigateRootOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.be.equal("https://example.com"); + expect(url).toEqual("https://example.com"); }); }); }); diff --git a/test/background/operators/impls/OpenHomeOperator.test.ts b/test/background/operators/impls/OpenHomeOperator.test.ts index 3c9288f..580aa49 100644 --- a/test/background/operators/impls/OpenHomeOperator.test.ts +++ b/test/background/operators/impls/OpenHomeOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import OpenHomeOperator from "../../../../src/background/operators/impls/OpenHomeOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockBrowserSettingRepository from "../../mock/MockBrowserSettingRepository"; @@ -20,7 +19,7 @@ describe("OpenHomeOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.be.equal("https://example.net/"); + expect(url).toEqual("https://example.net/"); }); it("opens a home page of the browser into a new tab", async () => { @@ -38,10 +37,7 @@ describe("OpenHomeOperator", () => { await sut.run(); const urls = (await tabPresenter.getAll()).map((t) => t.url); - expect(urls).to.be.deep.equal([ - "https://example.com/", - "https://example.net/", - ]); + expect(urls).toEqual(["https://example.com/", "https://example.net/"]); }); it("opens home pages of the browser", async () => { @@ -60,7 +56,7 @@ describe("OpenHomeOperator", () => { await sut.run(); const urls = (await tabPresenter.getAll()).map((t) => t.url); - expect(urls).to.be.deep.equal([ + expect(urls).toEqual([ "https://example.com/", "https://example.net/", "https://example.org/", diff --git a/test/background/operators/impls/OpenSourceOperator.test.ts b/test/background/operators/impls/OpenSourceOperator.test.ts index 541032b..4d9423c 100644 --- a/test/background/operators/impls/OpenSourceOperator.test.ts +++ b/test/background/operators/impls/OpenSourceOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import OpenSourceOperator from "../../../../src/background/operators/impls/OpenSourceOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -12,7 +11,7 @@ describe("OpenSourceOperator", () => { await sut.run(); const urls = (await tabPresenter.getAll()).map((t) => t.url); - expect(urls).to.be.deep.equal([ + expect(urls).toEqual([ "https://example.com/", "view-source:https://example.com/", ]); diff --git a/test/background/operators/impls/PinTabOperator.test.ts b/test/background/operators/impls/PinTabOperator.test.ts index 0c940b6..69082f2 100644 --- a/test/background/operators/impls/PinTabOperator.test.ts +++ b/test/background/operators/impls/PinTabOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import PinTabOperator from "../../../../src/background/operators/impls/PinTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -19,7 +18,7 @@ describe("PinTabOperator", () => { await sut.run(); const pins = (await tabPresenter.getAll()).map((t) => t.pinned); - expect(pins).to.deep.equal([true, false]); + expect(pins).toEqual([true, false]); }); }); }); diff --git a/test/background/operators/impls/ReloadTabOperator.test.ts b/test/background/operators/impls/ReloadTabOperator.test.ts index e87782b..0cedf3e 100644 --- a/test/background/operators/impls/ReloadTabOperator.test.ts +++ b/test/background/operators/impls/ReloadTabOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ReloadTabOperator from "../../../../src/background/operators/impls/ReloadTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -8,27 +7,28 @@ describe("ReloadTabOperator", () => { const tabPresenter = new MockTabPresenter(); await tabPresenter.create("https://example.com/", { active: true }); await tabPresenter.create("https://example.com/", { active: false }); - const mock = sinon.mock(tabPresenter).expects("reload").withArgs(0, true); + const reloadSpy = jest + .spyOn(tabPresenter, "reload") + .mockReturnValue(Promise.resolve()); const sut = new ReloadTabOperator(tabPresenter, true); await sut.run(); - mock.verify(); + expect(reloadSpy).toBeCalledWith(0, true); }); it("reloads the current tab without cache", async () => { const tabPresenter = new MockTabPresenter(); await tabPresenter.create("https://example.com/", { active: true }); await tabPresenter.create("https://example.com/", { active: false }); - const mock = sinon - .mock(tabPresenter) - .expects("reload") - .withArgs(0, false); + const reloadSpy = jest + .spyOn(tabPresenter, "reload") + .mockReturnValue(Promise.resolve()); const sut = new ReloadTabOperator(tabPresenter, false); await sut.run(); - mock.verify(); + expect(reloadSpy).toBeCalledWith(0, false); }); }); }); diff --git a/test/background/operators/impls/ReopenTabOperator.test.ts b/test/background/operators/impls/ReopenTabOperator.test.ts index 43b1575..5581f9a 100644 --- a/test/background/operators/impls/ReopenTabOperator.test.ts +++ b/test/background/operators/impls/ReopenTabOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ReopenTabOperator from "../../../../src/background/operators/impls/ReopenTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -6,12 +5,14 @@ describe("ReopenTabOperator", () => { describe("#run", () => { it("reopens closed tabs", async () => { const tabPresenter = new MockTabPresenter(); - const mock = sinon.mock(tabPresenter).expects("reopen"); + const reopenSpy = jest + .spyOn(tabPresenter, "reopen") + .mockReturnValue(Promise.resolve()); const sut = new ReopenTabOperator(tabPresenter); await sut.run(); - mock.verify(); + expect(reopenSpy).toBeCalled(); }); }); }); diff --git a/test/background/operators/impls/RepeatLastOperator.test.ts b/test/background/operators/impls/RepeatLastOperator.test.ts index 57f1227..fc37615 100644 --- a/test/background/operators/impls/RepeatLastOperator.test.ts +++ b/test/background/operators/impls/RepeatLastOperator.test.ts @@ -3,7 +3,6 @@ import MockRepeatRepository from "../../mock/MockRepeatRepository"; import OperatorFactory from "../../../../src/background/operators/OperatorFactory"; import * as operations from "../../../../src/shared/operations"; import Operator from "../../../../src/background/operators/Operator"; -import sinon from "sinon"; class MockOperatorFactory implements OperatorFactory { create(_op: operations.Operation): Operator { @@ -21,36 +20,34 @@ describe("RepeatLastOperator", () => { describe("#run", () => { it("repeat last operation", async () => { const operator = new MockOperator(); - const operatorMock = sinon.mock(operator).expects("run").once(); + const runSpy = jest + .spyOn(operator, "run") + .mockReturnValue(Promise.resolve()); + const repeatRepository = new MockRepeatRepository(); repeatRepository.setLastOperation({ type: operations.CANCEL }); const operatorFactory = new MockOperatorFactory(); - const operatorFactoryMock = sinon - .mock(operatorFactory) - .expects("create") - .withArgs({ type: operations.CANCEL }); - operatorFactoryMock.returns(operator); + const createSpy = jest + .spyOn(operatorFactory, "create") + .mockReturnValue(operator); const sut = new RepeatLastOperator(repeatRepository, operatorFactory); await sut.run(); - operatorFactoryMock.verify(); - operatorMock.verify(); + expect(runSpy).toBeCalledTimes(1); + expect(createSpy).toBeCalledWith({ type: operations.CANCEL }); }); it("does nothing if no last operations", async () => { const repeatRepository = new MockRepeatRepository(); const operatorFactory = new MockOperatorFactory(); - const operatorFactoryMock = sinon - .mock(operatorFactory) - .expects("create") - .never(); + const createSpy = jest.spyOn(operatorFactory, "create"); const sut = new RepeatLastOperator(repeatRepository, operatorFactory); await sut.run(); - operatorFactoryMock.verify(); + expect(createSpy).not.toBeCalled(); }); }); }); diff --git a/test/background/operators/impls/RepeatOperatorFactoryChain.test.ts b/test/background/operators/impls/RepeatOperatorFactoryChain.test.ts index e12d788..ec5e000 100644 --- a/test/background/operators/impls/RepeatOperatorFactoryChain.test.ts +++ b/test/background/operators/impls/RepeatOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import "reflect-metadata"; -import { expect } from "chai"; import RepeatOperatorFactoryChain from "../../../../src/background/operators/impls/RepeatOperatorFactoryChain"; import RepeatLastOperator from "../../../../src/background/operators/impls/RepeatLastOperator"; import OperatorFactory from "../../../../src/background/operators/OperatorFactory"; @@ -23,10 +22,10 @@ describe("RepeatOperatorFactoryChain", () => { operatorFactory ); - expect(sut.create({ type: operations.REPEAT_LAST })).to.be.instanceOf( + expect(sut.create({ type: operations.REPEAT_LAST })).toBeInstanceOf( RepeatLastOperator ); - expect(sut.create({ type: operations.CANCEL })).to.be.null; + expect(sut.create({ type: operations.CANCEL })).toBeNull; }); }); }); diff --git a/test/background/operators/impls/ResetZoomOperator.test.ts b/test/background/operators/impls/ResetZoomOperator.test.ts index 68cda05..40c56d9 100644 --- a/test/background/operators/impls/ResetZoomOperator.test.ts +++ b/test/background/operators/impls/ResetZoomOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ResetZoomOperator from "../../../../src/background/operators/impls/ResetZoomOperator"; import MockZoomPresenter from "../../mock/MockZoomPresenter"; @@ -6,12 +5,14 @@ describe("ResetZoomOperator", () => { describe("#run", () => { it("resets zoom on the tab", async () => { const zoomPresenter = new MockZoomPresenter(); - const mock = sinon.mock(zoomPresenter).expects("resetZoom").once(); + const resetZoomSpy = jest + .spyOn(zoomPresenter, "resetZoom") + .mockReturnValue(Promise.resolve()); const sut = new ResetZoomOperator(zoomPresenter); await sut.run(); - mock.verify(); + expect(resetZoomSpy).toBeCalled(); }); }); }); diff --git a/test/background/operators/impls/SelectFirstTabOperator.test.ts b/test/background/operators/impls/SelectFirstTabOperator.test.ts index a3f1d7e..ae8a42e 100644 --- a/test/background/operators/impls/SelectFirstTabOperator.test.ts +++ b/test/background/operators/impls/SelectFirstTabOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import SelectFirstTabOperator from "../../../../src/background/operators/impls/SelectFirstTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -14,7 +13,7 @@ describe("SelectFirstTabOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.equal("https://example.com/1"); + expect(url).toEqual("https://example.com/1"); }); }); }); diff --git a/test/background/operators/impls/SelectLastTabOperator.test.ts b/test/background/operators/impls/SelectLastTabOperator.test.ts index b8cf5c4..63668b1 100644 --- a/test/background/operators/impls/SelectLastTabOperator.test.ts +++ b/test/background/operators/impls/SelectLastTabOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import SelectLastTabOperator from "../../../../src/background/operators/impls/SelectLastTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -14,7 +13,7 @@ describe("SelectLastTabOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.equal("https://example.com/3"); + expect(url).toEqual("https://example.com/3"); }); }); }); diff --git a/test/background/operators/impls/SelectPreviousSelectedTabOperator.test.ts b/test/background/operators/impls/SelectPreviousSelectedTabOperator.test.ts index 5e6cc73..7872b2f 100644 --- a/test/background/operators/impls/SelectPreviousSelectedTabOperator.test.ts +++ b/test/background/operators/impls/SelectPreviousSelectedTabOperator.test.ts @@ -1,5 +1,3 @@ -import { expect } from "chai"; -import sinon from "sinon"; import MockTabPresenter from "../../mock/MockTabPresenter"; import SelectPreviousSelectedTabOperator from "../../../../src/background/operators/impls/SelectPreviousSelectedTabOperator"; @@ -10,13 +8,13 @@ describe("SelectPreviousSelectedTabOperator", () => { await tabPresenter.create("https://example.com/1", { active: false }); await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); - sinon.stub(tabPresenter, "getLastSelectedId").returns(Promise.resolve(0)); + jest.spyOn(tabPresenter, "getLastSelectedId").mockResolvedValue(0); const sut = new SelectPreviousSelectedTabOperator(tabPresenter); await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.equal("https://example.com/1"); + expect(url).toEqual("https://example.com/1"); }); it("do nothing if no last-selected tabs", async () => { @@ -24,15 +22,15 @@ describe("SelectPreviousSelectedTabOperator", () => { await tabPresenter.create("https://example.com/1", { active: false }); await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); - sinon - .stub(tabPresenter, "getLastSelectedId") - .returns(Promise.resolve(undefined)); - const mock = sinon.mock(tabPresenter).expects("select").never(); + jest + .spyOn(tabPresenter, "getLastSelectedId") + .mockResolvedValue(undefined); + const selectSpy = jest.spyOn(tabPresenter, "select"); const sut = new SelectPreviousSelectedTabOperator(tabPresenter); await sut.run(); - mock.verify(); + expect(selectSpy).not.toBeCalled(); }); }); }); diff --git a/test/background/operators/impls/SelectTabNextOperator.test.ts b/test/background/operators/impls/SelectTabNextOperator.test.ts index 5952d92..cc845e5 100644 --- a/test/background/operators/impls/SelectTabNextOperator.test.ts +++ b/test/background/operators/impls/SelectTabNextOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import MockTabPresenter from "../../mock/MockTabPresenter"; import SelectTabNextOperator from "../../../../src/background/operators/impls/SelectTabNextOperator"; @@ -14,7 +13,7 @@ describe("SelectTabNextOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.equal("https://example.com/3"); + expect(url).toEqual("https://example.com/3"); }); }); @@ -29,7 +28,7 @@ describe("SelectTabNextOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.equal("https://example.com/1"); + expect(url).toEqual("https://example.com/1"); }); }); }); diff --git a/test/background/operators/impls/SelectTabPrevOperator.test.ts b/test/background/operators/impls/SelectTabPrevOperator.test.ts index c9092fa..41df299 100644 --- a/test/background/operators/impls/SelectTabPrevOperator.test.ts +++ b/test/background/operators/impls/SelectTabPrevOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import MockTabPresenter from "../../mock/MockTabPresenter"; import SelectTabPrevOperator from "../../../../src/background/operators/impls/SelectTabPrevOperator"; @@ -14,7 +13,7 @@ describe("SelectTabPrevOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.equal("https://example.com/1"); + expect(url).toEqual("https://example.com/1"); }); }); @@ -29,7 +28,7 @@ describe("SelectTabPrevOperator", () => { await sut.run(); const url = (await tabPresenter.getCurrent()).url; - expect(url).to.equal("https://example.com/3"); + expect(url).toEqual("https://example.com/3"); }); }); }); diff --git a/test/background/operators/impls/ShowAddBookmarkOperator.test.ts b/test/background/operators/impls/ShowAddBookmarkOperator.test.ts index 1e083c2..aab7451 100644 --- a/test/background/operators/impls/ShowAddBookmarkOperator.test.ts +++ b/test/background/operators/impls/ShowAddBookmarkOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ShowAddBookmarkOperator from "../../../../src/background/operators/impls/ShowAddBookmarkOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -11,10 +10,9 @@ describe("ShowAddBookmarkOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "addbookmark "); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowAddBookmarkOperator( tabPresenter, @@ -23,7 +21,7 @@ describe("ShowAddBookmarkOperator", () => { ); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "addbookmark "); }); it("show command with addbookmark command and an URL of the current tab", async () => { @@ -32,10 +30,9 @@ describe("ShowAddBookmarkOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "addbookmark welcome, world"); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowAddBookmarkOperator( tabPresenter, @@ -44,7 +41,7 @@ describe("ShowAddBookmarkOperator", () => { ); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "addbookmark welcome, world"); }); }); }); diff --git a/test/background/operators/impls/ShowBufferCommandOperator.test.ts b/test/background/operators/impls/ShowBufferCommandOperator.test.ts index 91455b3..fbd1429 100644 --- a/test/background/operators/impls/ShowBufferCommandOperator.test.ts +++ b/test/background/operators/impls/ShowBufferCommandOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ShowBufferCommandOperator from "../../../../src/background/operators/impls/ShowBufferCommandOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -11,15 +10,14 @@ describe("ShowBufferCommandOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "buffer "); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowBufferCommandOperator(tabPresenter, consoleClient); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "buffer "); }); }); }); diff --git a/test/background/operators/impls/ShowCommandOperator.test.ts b/test/background/operators/impls/ShowCommandOperator.test.ts index 83b028c..c07176d 100644 --- a/test/background/operators/impls/ShowCommandOperator.test.ts +++ b/test/background/operators/impls/ShowCommandOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ShowCommandOperator from "../../../../src/background/operators/impls/ShowCommandOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -11,15 +10,14 @@ describe("ShowCommandOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, ""); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowCommandOperator(tabPresenter, consoleClient); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, ""); }); }); }); diff --git a/test/background/operators/impls/ShowOpenCommandOperator.test.ts b/test/background/operators/impls/ShowOpenCommandOperator.test.ts index 2c2105a..b4f631a 100644 --- a/test/background/operators/impls/ShowOpenCommandOperator.test.ts +++ b/test/background/operators/impls/ShowOpenCommandOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ShowOpenCommandOperator from "../../../../src/background/operators/impls/ShowOpenCommandOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -11,10 +10,9 @@ describe("ShowOpenCommandOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "open "); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowOpenCommandOperator( tabPresenter, @@ -23,7 +21,7 @@ describe("ShowOpenCommandOperator", () => { ); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "open "); }); it("show command with open command and an URL of the current tab", async () => { @@ -32,10 +30,9 @@ describe("ShowOpenCommandOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "open https://example.com/2"); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowOpenCommandOperator( tabPresenter, @@ -44,7 +41,7 @@ describe("ShowOpenCommandOperator", () => { ); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "open https://example.com/2"); }); }); }); diff --git a/test/background/operators/impls/ShowTabOpenCommandOperator.test.ts b/test/background/operators/impls/ShowTabOpenCommandOperator.test.ts index e291d05..1896a08 100644 --- a/test/background/operators/impls/ShowTabOpenCommandOperator.test.ts +++ b/test/background/operators/impls/ShowTabOpenCommandOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ShowTabOpenCommandOperator from "../../../../src/background/operators/impls/ShowTabOpenCommandOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -11,10 +10,9 @@ describe("ShowTabOpenCommandOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "tabopen "); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowTabOpenCommandOperator( tabPresenter, @@ -23,7 +21,7 @@ describe("ShowTabOpenCommandOperator", () => { ); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "tabopen "); }); it("show command with tabopen command and an URL of the current tab", async () => { @@ -32,10 +30,9 @@ describe("ShowTabOpenCommandOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "tabopen https://example.com/2"); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowTabOpenCommandOperator( tabPresenter, @@ -44,7 +41,7 @@ describe("ShowTabOpenCommandOperator", () => { ); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "tabopen https://example.com/2"); }); }); }); diff --git a/test/background/operators/impls/ShowWinOpenCommandOperator.test.ts b/test/background/operators/impls/ShowWinOpenCommandOperator.test.ts index c81a2d4..ce2a5b8 100644 --- a/test/background/operators/impls/ShowWinOpenCommandOperator.test.ts +++ b/test/background/operators/impls/ShowWinOpenCommandOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ShowWinOpenCommandOperator from "../../../../src/background/operators/impls/ShowWinOpenCommandOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -11,10 +10,9 @@ describe("ShowWinOpenCommandOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "winopen "); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowWinOpenCommandOperator( tabPresenter, @@ -23,7 +21,7 @@ describe("ShowWinOpenCommandOperator", () => { ); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "winopen "); }); it("show command with winopen command and an URL of the current tab", async () => { @@ -32,10 +30,9 @@ describe("ShowWinOpenCommandOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon - .mock(consoleClient) - .expects("showCommand") - .withArgs(1, "winopen https://example.com/2"); + const showCommandSpy = jest + .spyOn(consoleClient, "showCommand") + .mockReturnValue(Promise.resolve()); const sut = new ShowWinOpenCommandOperator( tabPresenter, @@ -44,7 +41,7 @@ describe("ShowWinOpenCommandOperator", () => { ); await sut.run(); - mock.verify(); + expect(showCommandSpy).toBeCalledWith(1, "winopen https://example.com/2"); }); }); }); diff --git a/test/background/operators/impls/StartFindOperator.test.ts b/test/background/operators/impls/StartFindOperator.test.ts index 7764520..23ebda8 100644 --- a/test/background/operators/impls/StartFindOperator.test.ts +++ b/test/background/operators/impls/StartFindOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import StartFindOperator from "../../../../src/background/operators/impls/StartFindOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; import MockConsoleClient from "../../mock/MockConsoleClient"; @@ -11,12 +10,14 @@ describe("StartFindOperator", () => { await tabPresenter.create("https://example.com/2", { active: true }); await tabPresenter.create("https://example.com/3", { active: false }); const consoleClient = new MockConsoleClient(); - const mock = sinon.mock(consoleClient).expects("showFind").withArgs(1); + const showFindSpy = jest + .spyOn(consoleClient, "showFind") + .mockReturnValue(Promise.resolve()); const sut = new StartFindOperator(tabPresenter, consoleClient); await sut.run(); - mock.verify(); + expect(showFindSpy).toBeCalledWith(1); }); }); }); diff --git a/test/background/operators/impls/TabOperatorFactoryChain.test.ts b/test/background/operators/impls/TabOperatorFactoryChain.test.ts index a777973..57e6321 100644 --- a/test/background/operators/impls/TabOperatorFactoryChain.test.ts +++ b/test/background/operators/impls/TabOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import "reflect-metadata"; -import { expect } from "chai"; import TabOperatorFactoryChain from "../../../../src/background/operators/impls/TabOperatorFactoryChain"; import MockTabPresenter from "../../mock/MockTabPresenter"; import DuplicateTabOperator from "../../../../src/background/operators/impls/DuplicateTabOperator"; @@ -23,49 +22,49 @@ describe("TabOperatorFactoryChain", () => { const tabPresenter = new MockTabPresenter(); const sut = new TabOperatorFactoryChain(tabPresenter); - expect(sut.create({ type: operations.TAB_CLOSE })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_CLOSE })).toBeInstanceOf( CloseTabOperator ); - expect(sut.create({ type: operations.TAB_CLOSE_RIGHT })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_CLOSE_RIGHT })).toBeInstanceOf( CloseTabRightOperator ); - expect(sut.create({ type: operations.TAB_CLOSE_FORCE })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_CLOSE_FORCE })).toBeInstanceOf( CloseTabOperator ); - expect(sut.create({ type: operations.TAB_REOPEN })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_REOPEN })).toBeInstanceOf( ReopenTabOperator ); - expect(sut.create({ type: operations.TAB_PREV })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_PREV })).toBeInstanceOf( SelectTabPrevOperator ); - expect(sut.create({ type: operations.TAB_NEXT })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_NEXT })).toBeInstanceOf( SelectTabNextOperator ); - expect(sut.create({ type: operations.TAB_FIRST })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_FIRST })).toBeInstanceOf( SelectFirstTabOperator ); - expect(sut.create({ type: operations.TAB_LAST })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_LAST })).toBeInstanceOf( SelectLastTabOperator ); - expect(sut.create({ type: operations.TAB_PREV_SEL })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_PREV_SEL })).toBeInstanceOf( SelectPreviousSelectedTabOperator ); expect( sut.create({ type: operations.TAB_RELOAD, cache: false }) - ).to.be.instanceOf(ReloadTabOperator); - expect(sut.create({ type: operations.TAB_PIN })).to.be.instanceOf( + ).toBeInstanceOf(ReloadTabOperator); + expect(sut.create({ type: operations.TAB_PIN })).toBeInstanceOf( PinTabOperator ); - expect(sut.create({ type: operations.TAB_UNPIN })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_UNPIN })).toBeInstanceOf( UnpinTabOperator ); - expect( - sut.create({ type: operations.TAB_TOGGLE_PINNED }) - ).to.be.instanceOf(TogglePinnedTabOperator); - expect(sut.create({ type: operations.TAB_DUPLICATE })).to.be.instanceOf( + expect(sut.create({ type: operations.TAB_TOGGLE_PINNED })).toBeInstanceOf( + TogglePinnedTabOperator + ); + expect(sut.create({ type: operations.TAB_DUPLICATE })).toBeInstanceOf( DuplicateTabOperator ); - expect(sut.create({ type: operations.CANCEL })).to.be.null; + expect(sut.create({ type: operations.CANCEL })).toBeNull; }); }); }); diff --git a/test/background/operators/impls/TogglePinnedTabOperator.test.ts b/test/background/operators/impls/TogglePinnedTabOperator.test.ts index f155f83..fbd6c39 100644 --- a/test/background/operators/impls/TogglePinnedTabOperator.test.ts +++ b/test/background/operators/impls/TogglePinnedTabOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import TogglePinnedTabOperator from "../../../../src/background/operators/impls/TogglePinnedTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -17,13 +16,13 @@ describe("TogglePinnedTabOperator", () => { const sut = new TogglePinnedTabOperator(tabPresenter); await sut.run(); - expect((await tabPresenter.getAll()).map((t) => t.pinned)).to.deep.equal([ + expect((await tabPresenter.getAll()).map((t) => t.pinned)).toEqual([ true, false, ]); await sut.run(); - expect((await tabPresenter.getAll()).map((t) => t.pinned)).to.deep.equal([ + expect((await tabPresenter.getAll()).map((t) => t.pinned)).toEqual([ false, false, ]); diff --git a/test/background/operators/impls/UnpinTabOperator.test.ts b/test/background/operators/impls/UnpinTabOperator.test.ts index 745f48c..c30c94f 100644 --- a/test/background/operators/impls/UnpinTabOperator.test.ts +++ b/test/background/operators/impls/UnpinTabOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import UnpinTabOperator from "../../../../src/background/operators/impls/UnpinTabOperator"; import MockTabPresenter from "../../mock/MockTabPresenter"; @@ -19,7 +18,7 @@ describe("UnpinTabOperator", () => { await sut.run(); const pins = (await tabPresenter.getAll()).map((t) => t.pinned); - expect(pins).to.deep.equal([false, true]); + expect(pins).toEqual([false, true]); }); }); }); diff --git a/test/background/operators/impls/ZoomInOperator.test.ts b/test/background/operators/impls/ZoomInOperator.test.ts index 097e760..1d42421 100644 --- a/test/background/operators/impls/ZoomInOperator.test.ts +++ b/test/background/operators/impls/ZoomInOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ZoomInOperator from "../../../../src/background/operators/impls/ZoomInOperator"; import MockZoomPresenter from "../../mock/MockZoomPresenter"; @@ -6,12 +5,14 @@ describe("ZoomInOperator", () => { describe("#run", () => { it("zoom-out the current tab", async () => { const zoomPresenter = new MockZoomPresenter(); - const mock = sinon.mock(zoomPresenter).expects("zoomIn").once(); + const zoomInSpy = jest + .spyOn(zoomPresenter, "zoomIn") + .mockReturnValue(Promise.resolve()); const sut = new ZoomInOperator(zoomPresenter); await sut.run(); - mock.verify(); + expect(zoomInSpy).toBeCalled(); }); }); }); diff --git a/test/background/operators/impls/ZoomOperatorFactoryChain.test.ts b/test/background/operators/impls/ZoomOperatorFactoryChain.test.ts index 10c1cee..ab40a86 100644 --- a/test/background/operators/impls/ZoomOperatorFactoryChain.test.ts +++ b/test/background/operators/impls/ZoomOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import "reflect-metadata"; -import { expect } from "chai"; import ZoomOperatorFactoryChain from "../../../../src/background/operators/impls/ZoomOperatorFactoryChain"; import MockZoomPresenter from "../../mock/MockZoomPresenter"; import ZoomInOperator from "../../../../src/background/operators/impls/ZoomInOperator"; @@ -13,16 +12,16 @@ describe("ZoomOperatorFactoryChain", () => { const zoomPresenter = new MockZoomPresenter(); const sut = new ZoomOperatorFactoryChain(zoomPresenter); - expect(sut.create({ type: operations.ZOOM_IN })).to.be.instanceOf( + expect(sut.create({ type: operations.ZOOM_IN })).toBeInstanceOf( ZoomInOperator ); - expect(sut.create({ type: operations.ZOOM_OUT })).to.be.instanceOf( + expect(sut.create({ type: operations.ZOOM_OUT })).toBeInstanceOf( ZoomOutOperator ); - expect(sut.create({ type: operations.ZOOM_NEUTRAL })).to.be.instanceOf( + expect(sut.create({ type: operations.ZOOM_NEUTRAL })).toBeInstanceOf( ResetZoomOperator ); - expect(sut.create({ type: operations.CANCEL })).to.be.null; + expect(sut.create({ type: operations.CANCEL })).toBeNull; }); }); }); diff --git a/test/background/operators/impls/ZoomOutOperator.test.ts b/test/background/operators/impls/ZoomOutOperator.test.ts index e0bbcd9..3165707 100644 --- a/test/background/operators/impls/ZoomOutOperator.test.ts +++ b/test/background/operators/impls/ZoomOutOperator.test.ts @@ -1,4 +1,3 @@ -import sinon from "sinon"; import ZoomOutOperator from "../../../../src/background/operators/impls/ZoomOutOperator"; import MockZoomPresenter from "../../mock/MockZoomPresenter"; @@ -6,12 +5,14 @@ describe("ZoomOutOperator", () => { describe("#run", () => { it("zoom-in the current tab", async () => { const zoomPresenter = new MockZoomPresenter(); - const mock = sinon.mock(zoomPresenter).expects("zoomOut").once(); + const zoomOutSpy = jest + .spyOn(zoomPresenter, "zoomOut") + .mockReturnValue(Promise.resolve()); const sut = new ZoomOutOperator(zoomPresenter); await sut.run(); - mock.verify(); + expect(zoomOutSpy).toBeCalled(); }); }); }); |