diff options
Diffstat (limited to 'test/background')
32 files changed, 133 insertions, 173 deletions
diff --git a/test/background/completion/OpenCompletionUseCase.test.ts b/test/background/completion/OpenCompletionUseCase.test.ts index f43e6c1..2284470 100644 --- a/test/background/completion/OpenCompletionUseCase.test.ts +++ b/test/background/completion/OpenCompletionUseCase.test.ts @@ -11,7 +11,6 @@ import CachedSettingRepository from "../../../src/background/repositories/Cached import Settings, { DefaultSetting, } from "../../../src/shared/settings/Settings"; -import { expect } from "chai"; import sinon from "sinon"; import Properties from "../../../src/shared/settings/Properties"; import Search from "../../../src/shared/settings/Search"; @@ -73,7 +72,7 @@ describe("OpenCompletionUseCase", () => { ); const items = await sut.getCompletionTypes(); - expect(items).to.deep.equal([ + expect(items).toEqual([ CompletionType.SearchEngines, CompletionType.History, CompletionType.Bookmarks, @@ -99,17 +98,17 @@ describe("OpenCompletionUseCase", () => { ) ); - expect(await sut.requestSearchEngines("")).to.deep.equal([ + expect(await sut.requestSearchEngines("")).toEqual([ "google", "yahoo", "bing", "googleja", ]); - expect(await sut.requestSearchEngines("go")).to.deep.equal([ + expect(await sut.requestSearchEngines("go")).toEqual([ "google", "googleja", ]); - expect(await sut.requestSearchEngines("x")).to.be.empty; + expect(await sut.requestSearchEngines("x")).toHaveLength(0); }); }); @@ -127,11 +126,11 @@ describe("OpenCompletionUseCase", () => { .withArgs("xyz") .returns(Promise.resolve([])); - expect(await sut.requestBookmarks("site")).to.deep.equal([ + expect(await sut.requestBookmarks("site")).toEqual([ { title: "site1", url: "https://site1.example.com" }, { title: "site2", url: "https://site2.example.com/" }, ]); - expect(await sut.requestBookmarks("xyz")).to.be.empty; + expect(await sut.requestBookmarks("xyz")).toHaveLength(0); }); }); @@ -149,11 +148,11 @@ describe("OpenCompletionUseCase", () => { .withArgs("xyz") .returns(Promise.resolve([])); - expect(await sut.requestHistory("site")).to.deep.equal([ + expect(await sut.requestHistory("site")).toEqual([ { title: "site1", url: "https://site1.example.com" }, { title: "site2", url: "https://site2.example.com/" }, ]); - expect(await sut.requestHistory("xyz")).to.be.empty; + expect(await sut.requestHistory("xyz")).toHaveLength(0); }); }); }); diff --git a/test/background/completion/PropertyCompletionUseCase.test.ts b/test/background/completion/PropertyCompletionUseCase.test.ts index dfc989f..b008eb5 100644 --- a/test/background/completion/PropertyCompletionUseCase.test.ts +++ b/test/background/completion/PropertyCompletionUseCase.test.ts @@ -1,6 +1,5 @@ import "reflect-metadata"; import PropertyCompletionUseCase from "../../../src/background/completion/PropertyCompletionUseCase"; -import { expect } from "chai"; describe("PropertyCompletionUseCase", () => { describe("getProperties", () => { @@ -8,11 +7,11 @@ describe("PropertyCompletionUseCase", () => { const sut = new PropertyCompletionUseCase(); const properties = await sut.getProperties(); - expect(properties).to.deep.contain({ + expect(properties).toContainEqual({ name: "smoothscroll", type: "boolean", }); - expect(properties).to.deep.contain({ name: "complete", type: "string" }); + expect(properties).toContainEqual({ name: "complete", type: "string" }); }); }); }); diff --git a/test/background/completion/TabCompletionUseCase.test.ts b/test/background/completion/TabCompletionUseCase.test.ts index 319f217..3b2723b 100644 --- a/test/background/completion/TabCompletionUseCase.test.ts +++ b/test/background/completion/TabCompletionUseCase.test.ts @@ -4,7 +4,6 @@ import { Tab } from "../../../src/background/completion/TabRepository"; import TabPresenter from "../../../src/background/presenters/TabPresenter"; import TabCompletionUseCase from "../../../src/background/completion/TabCompletionUseCase"; import sinon from "sinon"; -import { expect } from "chai"; import TabFlag from "../../../src/shared/TabFlag"; class MockTabRepository implements TabRepositoryImpl { @@ -182,7 +181,7 @@ describe("TabCompletionUseCase", () => { ]) ); - expect(await sut.queryTabs("", false)).to.deep.equal([ + expect(await sut.queryTabs("", false)).toEqual([ { index: 1, title: "Google", @@ -206,7 +205,7 @@ describe("TabCompletionUseCase", () => { }, ]); - expect(await sut.queryTabs("oo", false)).to.deep.equal([ + expect(await sut.queryTabs("oo", false)).toEqual([ { index: 1, title: "Google", @@ -225,7 +224,7 @@ describe("TabCompletionUseCase", () => { }); it("returns a tab by the index", async () => { - expect(await sut.queryTabs("1", false)).to.deep.equal([ + expect(await sut.queryTabs("1", false)).toEqual([ { index: 1, title: "Google", @@ -235,12 +234,12 @@ describe("TabCompletionUseCase", () => { }, ]); - expect(await sut.queryTabs("10", false)).to.be.empty; - expect(await sut.queryTabs("-1", false)).to.be.empty; + expect(await sut.queryTabs("10", false)).toHaveLength(0); + expect(await sut.queryTabs("-1", false)).toHaveLength(0); }); it("returns the current tab by % flag", async () => { - expect(await sut.queryTabs("%", false)).to.deep.equal([ + expect(await sut.queryTabs("%", false)).toEqual([ { index: 2, title: "Yahoo", @@ -252,7 +251,7 @@ describe("TabCompletionUseCase", () => { }); it("returns the current tab by # flag", async () => { - expect(await sut.queryTabs("#", false)).to.deep.equal([ + expect(await sut.queryTabs("#", false)).toEqual([ { index: 3, title: "Bing", diff --git a/test/background/completion/impl/filters.test.ts b/test/background/completion/impl/filters.test.ts index b160944..5dd1a93 100644 --- a/test/background/completion/impl/filters.test.ts +++ b/test/background/completion/impl/filters.test.ts @@ -1,5 +1,4 @@ import * as filters from "../../../../src/background/completion/impl/filters"; -import { expect } from "chai"; describe("background/usecases/filters", () => { describe("filterHttp", () => { @@ -13,7 +12,7 @@ describe("background/usecases/filters", () => { const filtered = filters.filterHttp(pages); const urls = filtered.map((x) => x.url); - expect(urls).to.deep.equal([ + expect(urls).toEqual([ "https://i-beam.org/bar", "http://i-beam.net/hoge", "http://i-beam.net/fuga", @@ -30,7 +29,7 @@ describe("background/usecases/filters", () => { ]; const filtered = filters.filterBlankTitle(pages); - expect(filtered).to.deep.equal([{ id: "0", title: "hello" }]); + expect(filtered).toEqual([{ id: "0", title: "hello" }]); }); }); @@ -45,7 +44,7 @@ describe("background/usecases/filters", () => { const filtered = filters.filterByTailingSlash(pages); const urls = filtered.map((x) => x.url); - expect(urls).to.deep.equal([ + expect(urls).toEqual([ "http://i-beam.org/content", "http://i-beam.org/search", "http://i-beam.org/search?q=apple_banana_cherry", @@ -64,7 +63,7 @@ describe("background/usecases/filters", () => { { id: "5", url: "http://i-beam.org/request?q=apple_banana_cherry" }, ]; const filtered = filters.filterByPathname(pages, 10); - expect(filtered).to.have.lengthOf(6); + expect(filtered).toHaveLength(6); }); it("filters by length of pathname", () => { @@ -77,7 +76,7 @@ describe("background/usecases/filters", () => { { id: "5", url: "http://i-beam.net/search?q=apple_banana_cherry" }, ]; const filtered = filters.filterByPathname(pages, 0); - expect(filtered).to.deep.equal([ + expect(filtered).toEqual([ { id: "0", url: "http://i-beam.org/search?q=apple" }, { id: "3", url: "http://i-beam.net/search?q=apple" }, ]); @@ -95,7 +94,7 @@ describe("background/usecases/filters", () => { { id: "5", url: "http://i-beam.org/request?q=apple_banana_cherry" }, ]; const filtered = filters.filterByOrigin(pages, 10); - expect(filtered).to.have.lengthOf(6); + expect(filtered).toHaveLength(6); }); it("filters by length of pathname", () => { @@ -108,7 +107,7 @@ describe("background/usecases/filters", () => { { id: "5", url: "http://i-beam.org/request?q=apple_banana_cherry" }, ]; const filtered = filters.filterByOrigin(pages, 0); - expect(filtered).to.deep.equal([ + expect(filtered).toEqual([ { id: "0", url: "http://i-beam.org/search?q=apple" }, ]); }); diff --git a/test/background/infrastructures/MemoryStorage.test.ts b/test/background/infrastructures/MemoryStorage.test.ts index 1c67b18..6618549 100644 --- a/test/background/infrastructures/MemoryStorage.test.ts +++ b/test/background/infrastructures/MemoryStorage.test.ts @@ -1,22 +1,21 @@ import MemoryStorage from "../../../src/background/infrastructures/MemoryStorage"; -import { expect } from "chai"; describe("background/infrastructures/memory-storage", () => { it("stores values", () => { const cache = new MemoryStorage(); cache.set("number", 123); - expect(cache.get("number")).to.equal(123); + expect(cache.get("number")).toEqual(123); cache.set("string", "123"); - expect(cache.get("string")).to.equal("123"); + expect(cache.get("string")).toEqual("123"); cache.set("object", { hello: "123" }); - expect(cache.get("object")).to.deep.equal({ hello: "123" }); + expect(cache.get("object")).toEqual({ hello: "123" }); }); it("returns undefined if no keys", () => { const cache = new MemoryStorage(); - expect(cache.get("no-keys")).to.be.undefined; + expect(cache.get("no-keys")).toBeUndefined; }); it("stored on shared memory", () => { @@ -25,7 +24,7 @@ describe("background/infrastructures/memory-storage", () => { cache = new MemoryStorage(); const got = cache.get("red"); - expect(got).to.equal("apple"); + expect(got).toEqual("apple"); }); it("stored cloned objects", () => { @@ -35,11 +34,11 @@ describe("background/infrastructures/memory-storage", () => { recipe.salt = "20g"; const got = cache.get("recipe"); - expect(got).to.deep.equal({ sugar: "300g", salt: "10g" }); + expect(got).toEqual({ sugar: "300g", salt: "10g" }); }); it("throws an error with unserializable objects", () => { const cache = new MemoryStorage(); - expect(() => cache.set("fn", setTimeout)).to.throw(); + expect(() => cache.set("fn", setTimeout)).toThrow(); }); }); 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/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/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/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/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/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..5d6827d 100644 --- a/test/background/operators/impls/SelectPreviousSelectedTabOperator.test.ts +++ b/test/background/operators/impls/SelectPreviousSelectedTabOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import sinon from "sinon"; import MockTabPresenter from "../../mock/MockTabPresenter"; import SelectPreviousSelectedTabOperator from "../../../../src/background/operators/impls/SelectPreviousSelectedTabOperator"; @@ -16,7 +15,7 @@ describe("SelectPreviousSelectedTabOperator", () => { 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 () => { 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/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/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/repositories/FindRepository.test.ts b/test/background/repositories/FindRepository.test.ts index d8c9506..88d5e71 100644 --- a/test/background/repositories/FindRepository.test.ts +++ b/test/background/repositories/FindRepository.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import { FindRepositoryImpl } from "../../../src/background/repositories/FindRepository"; describe("background/repositories/FindRepositoryImpl", () => { @@ -10,18 +9,18 @@ describe("background/repositories/FindRepositoryImpl", () => { describe("global keyword", () => { it("get and set a keyword", async () => { - expect(await sut.getGlobalKeyword()).to.be.undefined; + expect(await sut.getGlobalKeyword()).toBeUndefined; await sut.setGlobalKeyword("Hello, world"); const keyword = await sut.getGlobalKeyword(); - expect(keyword).to.equal("Hello, world"); + expect(keyword).toEqual("Hello, world"); }); }); describe("local state", () => { it("get and set a keyword", async () => { - expect(await sut.getLocalState(10)).to.be.undefined; + expect(await sut.getLocalState(10)).toBeUndefined; await sut.setLocalState(10, { keyword: "Hello, world", @@ -29,10 +28,10 @@ describe("background/repositories/FindRepositoryImpl", () => { }); const state = await sut.getLocalState(10); - expect(state?.keyword).to.equal("Hello, world"); - expect(state?.frameId).to.equal(11); + expect(state?.keyword).toEqual("Hello, world"); + expect(state?.frameId).toEqual(11); - expect(await sut.getLocalState(20)).to.be.undefined; + 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 index 71f20af..fb4d34a 100644 --- a/test/background/repositories/ReadyFrameRepository.test.ts +++ b/test/background/repositories/ReadyFrameRepository.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import { ReadyFrameRepositoryImpl } from "../../../src/background/repositories/ReadyFrameRepository"; describe("background/repositories/ReadyFrameRepositoryImpl", () => { @@ -9,7 +8,7 @@ describe("background/repositories/ReadyFrameRepositoryImpl", () => { }); it("get and set a keyword", async () => { - expect(await sut.getFrameIds(1)).to.be.undefined; + expect(await sut.getFrameIds(1)).toBeUndefined; await sut.addFrameId(1, 10); await sut.addFrameId(1, 12); @@ -18,16 +17,16 @@ describe("background/repositories/ReadyFrameRepositoryImpl", () => { await sut.addFrameId(2, 21); await sut.addFrameId(2, 21); - expect(await sut.getFrameIds(1)).to.deep.equal([10, 11, 12]); - expect(await sut.getFrameIds(2)).to.deep.equal([20, 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)).to.deep.equal([20, 21]); + expect(await sut.getFrameIds(2)).toEqual([20, 21]); await sut.removeFrameId(2, 21); - expect(await sut.getFrameIds(2)).to.deep.equal([20]); + expect(await sut.getFrameIds(2)).toEqual([20]); await sut.removeFrameId(2, 20); - expect(await sut.getFrameIds(2)).to.be.undefined; + expect(await sut.getFrameIds(2)).toBeUndefined; }); }); diff --git a/test/background/usecases/SettingUseCase.test.ts b/test/background/usecases/SettingUseCase.test.ts index 54b6711..af2fb1e 100644 --- a/test/background/usecases/SettingUseCase.test.ts +++ b/test/background/usecases/SettingUseCase.test.ts @@ -7,7 +7,6 @@ import Settings, { DefaultSetting, } from "../../../src/shared/settings/Settings"; import Notifier from "../../../src/background/presenters/Notifier"; -import { expect } from "chai"; import Properties from "../../../src/shared/settings/Properties"; import sinon from "sinon"; @@ -82,7 +81,7 @@ describe("SettingUseCase", () => { .returns(Promise.resolve(settings)); const got = await sut.getCached(); - expect(got.properties.hintchars).to.equal("abcd1234"); + expect(got.properties.hintchars).toEqual("abcd1234"); }); }); @@ -112,7 +111,7 @@ describe("SettingUseCase", () => { await sut.reload(); const current = await cachedSettingRepository.get(); - expect(current.properties.hintchars).to.equal("abcd1234"); + expect(current.properties.hintchars).toEqual("abcd1234"); }); }); @@ -141,7 +140,7 @@ describe("SettingUseCase", () => { await sut.reload(); const current = await cachedSettingRepository.get(); - expect(current.properties.hintchars).to.equal("aaaa1111"); + expect(current.properties.hintchars).toEqual("aaaa1111"); }); }); @@ -157,7 +156,7 @@ describe("SettingUseCase", () => { await sut.reload(); const current = await cachedSettingRepository.get(); - expect(current.properties.hintchars).to.equal( + expect(current.properties.hintchars).toEqual( DefaultSetting.properties.hintchars ); }); diff --git a/test/background/usecases/parsers.test.ts b/test/background/usecases/parsers.test.ts index 019b56e..db26b7a 100644 --- a/test/background/usecases/parsers.test.ts +++ b/test/background/usecases/parsers.test.ts @@ -1,42 +1,36 @@ import * as parsers from "../../../src/background/usecases/parsers"; -import { expect } from "chai"; describe("shared/commands/parsers", () => { describe("#parsers.parseSetOption", () => { it("parse set string", () => { const [key, value] = parsers.parseSetOption("hintchars=abcdefgh"); - expect(key).to.equal("hintchars"); - expect(value).to.equal("abcdefgh"); + expect(key).toEqual("hintchars"); + expect(value).toEqual("abcdefgh"); }); it("parse set empty string", () => { const [key, value] = parsers.parseSetOption("hintchars="); - expect(key).to.equal("hintchars"); - expect(value).to.equal(""); + expect(key).toEqual("hintchars"); + expect(value).toEqual(""); }); it("parse set boolean", () => { let [key, value] = parsers.parseSetOption("smoothscroll"); - expect(key).to.equal("smoothscroll"); - expect(value).to.be.true; + expect(key).toEqual("smoothscroll"); + expect(value).toBeTruthy; [key, value] = parsers.parseSetOption("nosmoothscroll"); - expect(key).to.equal("smoothscroll"); - expect(value).to.be.false; + expect(key).toEqual("smoothscroll"); + expect(value).toBeFalsy; }); it("throws error on unknown property", () => { - expect(() => parsers.parseSetOption("encoding=utf-8")).to.throw( - Error, + expect(() => parsers.parseSetOption("encoding=utf-8")).toThrowError( "Unknown" ); - expect(() => parsers.parseSetOption("paste")).to.throw(Error, "Unknown"); - expect(() => parsers.parseSetOption("nopaste")).to.throw( - Error, - "Unknown" - ); - expect(() => parsers.parseSetOption("smoothscroll=yes")).to.throw( - Error, + expect(() => parsers.parseSetOption("paste")).toThrowError("Unknown"); + expect(() => parsers.parseSetOption("nopaste")).toThrowError("Unknown"); + expect(() => parsers.parseSetOption("smoothscroll=yes")).toThrowError( "Invalid argument" ); }); |