From e304581fb15eabb3a973d363a282ee7546561e01 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 26 Sep 2021 17:01:31 +0900 Subject: Do not use chai on unit test --- .../completion/OpenCompletionUseCase.test.ts | 17 ++-- .../completion/PropertyCompletionUseCase.test.ts | 5 +- .../completion/TabCompletionUseCase.test.ts | 15 ++-- test/background/completion/impl/filters.test.ts | 15 ++-- .../infrastructures/MemoryStorage.test.ts | 15 ++-- .../operators/impls/CloseTabOperator.test.ts | 7 +- .../operators/impls/CloseTabRightOperator.test.ts | 3 +- .../impls/CommandOperatorFactoryChain.test.ts | 15 ++-- .../operators/impls/DuplicateTabOperator.test.ts | 3 +- .../operators/impls/FindOperatorFactoryChain.ts | 5 +- .../impls/InternalOperatorFactoryChain.test.ts | 7 +- .../impls/NavigateOperatorFactoryChain.test.ts | 19 ++--- .../operators/impls/NavigateParentOperator.test.ts | 9 +- .../operators/impls/NavigateRootOperator.test.ts | 3 +- .../operators/impls/OpenHomeOperator.test.ts | 10 +-- .../operators/impls/OpenSourceOperator.test.ts | 3 +- .../operators/impls/PinTabOperator.test.ts | 3 +- .../impls/RepeatOperatorFactoryChain.test.ts | 5 +- .../operators/impls/SelectFirstTabOperator.test.ts | 3 +- .../operators/impls/SelectLastTabOperator.test.ts | 3 +- .../SelectPreviousSelectedTabOperator.test.ts | 3 +- .../operators/impls/SelectTabNextOperator.test.ts | 5 +- .../operators/impls/SelectTabPrevOperator.test.ts | 5 +- .../impls/TabOperatorFactoryChain.test.ts | 35 ++++---- .../impls/TogglePinnedTabOperator.test.ts | 5 +- .../operators/impls/UnpinTabOperator.test.ts | 3 +- .../impls/ZoomOperatorFactoryChain.test.ts | 9 +- .../background/repositories/FindRepository.test.ts | 13 ++- test/background/repositories/Mark.test.ts | 11 ++- .../repositories/ReadyFrameRepository.test.ts | 13 ++- test/background/usecases/SettingUseCase.test.ts | 9 +- test/background/usecases/parsers.test.ts | 30 +++---- test/console/app/actions.test.ts | 19 ++--- test/console/app/reducer.test.ts | 21 +++-- test/console/commandline/CommandLineParser.test.ts | 13 ++- test/console/commandline/CommandParser.test.ts | 9 +- test/console/completion/reducer.test.ts | 31 ++++--- test/console/components/ErrorMessage.test.tsx | 5 +- test/console/components/InfoMessage.test.tsx | 5 +- .../console/components/console/Completion.test.tsx | 43 +++++----- .../components/console/CompletionItem.test.tsx | 7 +- .../components/console/CompletionTitle.test.tsx | 3 +- test/content/InputDriver.test.ts | 67 ++++++++------- test/content/domains/KeySequence.test.ts | 77 ++++++++---------- .../impls/AddonOperatorFactoryChain.test.ts | 13 ++- .../impls/BackgroundOperationOperator.test.ts | 3 +- .../impls/ClipboardOperatorFactoryChain.test.ts | 7 +- .../operators/impls/DisableAddonOperator.test.ts | 7 +- .../operators/impls/EnableAddonOperator.test.ts | 7 +- .../operators/impls/EnableJumpMarkOperator.test.ts | 3 +- .../operators/impls/EnableSetMarkOperator.test.ts | 3 +- .../impls/FocusOperatorFactoryChain.test.ts | 5 +- .../impls/FollowOperatorFactoryChain.test.ts | 5 +- .../impls/HorizontalScrollOperator.test.ts | 5 +- .../impls/MarkOperatorFactoryChain.test.ts | 7 +- .../operators/impls/PageScrollOperator.test.ts | 5 +- .../impls/ScrollOperatorFactoryChain.test.ts | 23 +++--- .../operators/impls/ScrollToBottomOperator.test.ts | 3 +- .../operators/impls/ScrollToEndOperator.test.ts | 3 +- .../operators/impls/ScrollToHomeOperator.test.ts | 3 +- .../operators/impls/ScrollToTopOperator.test.ts | 3 +- .../operators/impls/ToggleAddonOperator.test.ts | 13 ++- .../operators/impls/VerticalScrollOperator.test.ts | 5 +- .../operators/impls/YankURLOperator.test.ts | 7 +- test/content/presenters/Hint.test.ts | 23 +++--- .../content/presenters/NavigationPresenter.test.ts | 3 +- .../repositories/AddonEnabledRepository.test.ts | 5 +- .../repositories/FollowKeyRepository.test.ts | 9 +- .../repositories/FollowMasterRepository.test.ts | 23 +++--- .../repositories/FollowSlaveRepository.test.ts | 7 +- test/content/repositories/KeymapRepository.test.ts | 9 +- .../content/repositories/MarkKeyRepository.test.ts | 13 ++- test/content/repositories/MarkRepository.test.ts | 5 +- .../content/repositories/SettingRepository.test.ts | 3 +- test/content/usecases/AddonEnabledUseCase.test.ts | 29 ++++--- test/content/usecases/HintKeyProducer.test.ts | 13 ++- test/content/usecases/KeymapUseCase.test.ts | 89 ++++++++++---------- test/content/usecases/MarkUseCase.test.ts | 15 ++-- test/content/usecases/SettingUseCaase.test.ts | 5 +- .../components/form/BlacklistForm.test.tsx | 20 ++--- test/settings/components/form/KeymapsForm.test.tsx | 11 ++- .../components/form/PropertiesForm.test.tsx | 19 ++--- .../components/form/SearchEngineForm.test.tsx | 33 ++++---- test/settings/components/ui/Radio.test.tsx | 11 ++- test/settings/components/ui/Text.test.tsx | 11 ++- test/settings/components/ui/TextArea.test.tsx | 15 ++-- test/settings/reducers/setting.test.ts | 23 +++--- test/shared/SettingData.test.ts | 25 +++--- test/shared/operations.test.ts | 15 ++-- test/shared/settings/Blacklist.test.ts | 83 ++++++++++--------- test/shared/settings/Key.test.ts | 95 +++++++++++----------- test/shared/settings/Keymaps.test.ts | 13 ++- test/shared/settings/Properties.test.ts | 5 +- test/shared/settings/Search.test.ts | 15 ++-- test/shared/settings/Settings.test.ts | 15 ++-- test/shared/urls.test.ts | 33 ++++---- 96 files changed, 657 insertions(+), 772 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" ); }); diff --git a/test/console/app/actions.test.ts b/test/console/app/actions.test.ts index 2f9dc71..d4b4568 100644 --- a/test/console/app/actions.test.ts +++ b/test/console/app/actions.test.ts @@ -7,7 +7,6 @@ import { SHOW_FIND, SHOW_INFO, } from "../../../src/console/app/actions"; -import { expect } from "chai"; import browserFake from "webextensions-api-fake"; @@ -19,44 +18,44 @@ describe("console actions", () => { describe("hide", () => { it("create CONSOLE_HIDE action", () => { const action = consoleActions.hide(); - expect(action.type).to.equal(HIDE); + expect(action.type).toEqual(HIDE); }); }); describe("showCommand", () => { it("create CONSOLE_SHOW_COMMAND action", async () => { const action = await consoleActions.showCommand("hello"); - expect(action.type).to.equal(SHOW_COMMAND); - expect(action.text).to.equal("hello"); + expect(action.type).toEqual(SHOW_COMMAND); + expect(action.text).toEqual("hello"); }); }); describe("showFind", () => { it("create CONSOLE_SHOW_FIND action", () => { const action = consoleActions.showFind(); - expect(action.type).to.equal(SHOW_FIND); + expect(action.type).toEqual(SHOW_FIND); }); }); describe("showError", () => { it("create CONSOLE_SHOW_ERROR action", () => { const action = consoleActions.showError("an error"); - expect(action.type).to.equal(SHOW_ERROR); - expect(action.text).to.equal("an error"); + expect(action.type).toEqual(SHOW_ERROR); + expect(action.text).toEqual("an error"); }); }); describe("showInfo", () => { it("create CONSOLE_SHOW_INFO action", () => { const action = consoleActions.showInfo("an info"); - expect(action.type).to.equal(SHOW_INFO); - expect(action.text).to.equal("an info"); + expect(action.type).toEqual(SHOW_INFO); + expect(action.text).toEqual("an info"); }); }); describe("hideCommand", () => { it("create CONSOLE_HIDE_COMMAND action", () => { const action = consoleActions.hideCommand(); - expect(action.type).to.equal(HIDE_COMMAND); + expect(action.type).toEqual(HIDE_COMMAND); }); }); }); diff --git a/test/console/app/reducer.test.ts b/test/console/app/reducer.test.ts index 4406adc..eac2012 100644 --- a/test/console/app/reducer.test.ts +++ b/test/console/app/reducer.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import reducer, { defaultState, State } from "../../../src/console/app/recuer"; import { hide, @@ -18,7 +17,7 @@ describe("app reducer", () => { }; const nextState = reducer(initialState, hide()); - expect(nextState.mode).to.be.empty; + expect(nextState.mode).toHaveLength(0); }); }); @@ -26,8 +25,8 @@ describe("app reducer", () => { it("switches to command mode with a message", () => { const nextState = reducer(defaultState, showCommand("open ")); - expect(nextState.mode).equals("command"); - expect(nextState.consoleText).equals("open "); + expect(nextState.mode).toEqual("command"); + expect(nextState.consoleText).toEqual("open "); }); }); @@ -35,7 +34,7 @@ describe("app reducer", () => { it("switches to find mode with a message", () => { const nextState = reducer(defaultState, showFind()); - expect(nextState.mode).equals("find"); + expect(nextState.mode).toEqual("find"); }); }); @@ -43,8 +42,8 @@ describe("app reducer", () => { it("switches to error message mode with a message", () => { const nextState = reducer(defaultState, showError("error occurs")); - expect(nextState.mode).equals("error"); - expect(nextState.messageText).equals("error occurs"); + expect(nextState.mode).toEqual("error"); + expect(nextState.messageText).toEqual("error occurs"); }); }); @@ -52,8 +51,8 @@ describe("app reducer", () => { it("switches to info message mode with a message", () => { const nextState = reducer(defaultState, showInfo("what's up")); - expect(nextState.mode).equals("info"); - expect(nextState.messageText).equals("what's up"); + expect(nextState.mode).toEqual("info"); + expect(nextState.messageText).toEqual("what's up"); }); }); @@ -66,7 +65,7 @@ describe("app reducer", () => { }; const nextState = reducer(initialState, hideCommand()); - expect(nextState.mode).to.be.empty; + expect(nextState.mode).toHaveLength(0); }); }); @@ -78,7 +77,7 @@ describe("app reducer", () => { }; const nextState = reducer(initialState, hideCommand()); - expect(nextState.mode).equals("info"); + expect(nextState.mode).toEqual("info"); }); }); }); diff --git a/test/console/commandline/CommandLineParser.test.ts b/test/console/commandline/CommandLineParser.test.ts index 7cba04c..d187e1e 100644 --- a/test/console/commandline/CommandLineParser.test.ts +++ b/test/console/commandline/CommandLineParser.test.ts @@ -2,27 +2,26 @@ import CommandLineParser, { InputPhase, } from "../../../src/console/commandline/CommandLineParser"; import { Command } from "../../../src/shared/Command"; -import { expect } from "chai"; describe("CommandLineParser", () => { describe("#inputPhase", () => { it("returns parsed command-line", () => { const sut = new CommandLineParser(); - expect(sut.inputPhase("")).to.equal(InputPhase.OnCommand); - expect(sut.inputPhase("op")).to.equal(InputPhase.OnCommand); - expect(sut.inputPhase("open ")).to.equal(InputPhase.OnArgs); - expect(sut.inputPhase("open apple")).to.equal(InputPhase.OnArgs); + expect(sut.inputPhase("")).toEqual(InputPhase.OnCommand); + expect(sut.inputPhase("op")).toEqual(InputPhase.OnCommand); + expect(sut.inputPhase("open ")).toEqual(InputPhase.OnArgs); + expect(sut.inputPhase("open apple")).toEqual(InputPhase.OnArgs); }); }); describe("#parse", () => { it("returns parsed command-line", () => { const sut = new CommandLineParser(); - expect(sut.parse("open google apple")).to.deep.equal({ + expect(sut.parse("open google apple")).toEqual({ command: Command.Open, args: "google apple", }); - expect(sut.parse("qa")).to.deep.equal({ + expect(sut.parse("qa")).toEqual({ command: Command.QuitAll, args: "", }); diff --git a/test/console/commandline/CommandParser.test.ts b/test/console/commandline/CommandParser.test.ts index f72afd6..a8e82df 100644 --- a/test/console/commandline/CommandParser.test.ts +++ b/test/console/commandline/CommandParser.test.ts @@ -2,16 +2,15 @@ import CommandParser, { UnknownCommandError, } from "../../../src/console/commandline/CommandParser"; import { Command } from "../../../src/shared/Command"; -import { expect } from "chai"; describe("CommandParser", () => { describe("#parse", () => { it("returns matched command with the string", () => { const sut = new CommandParser(); - expect(sut.parse("open")).to.equal(Command.Open); - expect(sut.parse("w")).to.equal(Command.WindowOpen); - expect(sut.parse("bdelete!")).to.equal(Command.BufferDeleteForce); - expect(() => sut.parse("harakiri")).to.throw(UnknownCommandError); + expect(sut.parse("open")).toEqual(Command.Open); + expect(sut.parse("w")).toEqual(Command.WindowOpen); + expect(sut.parse("bdelete!")).toEqual(Command.BufferDeleteForce); + expect(() => sut.parse("harakiri")).toThrow(UnknownCommandError); }); }); }); diff --git a/test/console/completion/reducer.test.ts b/test/console/completion/reducer.test.ts index 91a6751..43b9807 100644 --- a/test/console/completion/reducer.test.ts +++ b/test/console/completion/reducer.test.ts @@ -2,7 +2,6 @@ import reducer, { defaultState, State, } from "../../../src/console/completion/reducer"; -import { expect } from "chai"; import { initCompletion, selectNext, @@ -20,7 +19,7 @@ describe("completion reducer", () => { initCompletion([CompletionType.Bookmarks, CompletionType.History]) ); - expect(nextState.completionTypes).deep.equals([ + expect(nextState.completionTypes).toEqual([ CompletionType.Bookmarks, CompletionType.History, ]); @@ -31,7 +30,7 @@ describe("completion reducer", () => { it("sets a completion source", () => { const nextState = reducer(defaultState, setCompletionSource("open ")); - expect(nextState.completionSource).equals("open "); + expect(nextState.completionSource).toEqual("open "); }); }); @@ -51,7 +50,7 @@ describe("completion reducer", () => { ]) ); - expect(nextState.completions).deep.equals([ + expect(nextState.completions).toEqual([ { name: "Apple", items: [{}, {}], @@ -68,7 +67,7 @@ describe("completion reducer", () => { describe("when no completion groups", () => { it("does nothing", () => { const nextState = reducer(defaultState, selectNext()); - expect(nextState.select).equals(-1); + expect(nextState.select).toEqual(-1); }); }); @@ -79,7 +78,7 @@ describe("completion reducer", () => { completions: [{ name: "apple", items: [] }], }; const nextState = reducer(state, selectNext()); - expect(nextState.select).equals(-1); + expect(nextState.select).toEqual(-1); }); }); @@ -101,16 +100,16 @@ describe("completion reducer", () => { }; state = reducer(state, selectNext()); - expect(state.select).equals(0); + expect(state.select).toEqual(0); state = reducer(state, selectNext()); - expect(state.select).equals(1); + expect(state.select).toEqual(1); state = reducer(state, selectNext()); - expect(state.select).equals(2); + expect(state.select).toEqual(2); state = reducer(state, selectNext()); - expect(state.select).equals(-1); + expect(state.select).toEqual(-1); }); }); }); @@ -119,7 +118,7 @@ describe("completion reducer", () => { describe("when no completion groups", () => { it("does nothing", () => { const nextState = reducer(defaultState, selectPrev()); - expect(nextState.select).equals(-1); + expect(nextState.select).toEqual(-1); }); describe("when no completion items", () => { @@ -129,7 +128,7 @@ describe("completion reducer", () => { completions: [{ name: "apple", items: [] }], }; const nextState = reducer(state, selectPrev()); - expect(nextState.select).equals(-1); + expect(nextState.select).toEqual(-1); }); }); }); @@ -152,16 +151,16 @@ describe("completion reducer", () => { }; state = reducer(state, selectPrev()); - expect(state).to.have.property("select", 2); + expect(state).toHaveProperty("select", 2); state = reducer(state, selectPrev()); - expect(state).to.have.property("select", 1); + expect(state).toHaveProperty("select", 1); state = reducer(state, selectPrev()); - expect(state).to.have.property("select", 0); + expect(state).toHaveProperty("select", 0); state = reducer(state, selectPrev()); - expect(state).to.have.property("select", -1); + expect(state).toHaveProperty("select", -1); }); }); }); diff --git a/test/console/components/ErrorMessage.test.tsx b/test/console/components/ErrorMessage.test.tsx index 5097bc1..45b3052 100644 --- a/test/console/components/ErrorMessage.test.tsx +++ b/test/console/components/ErrorMessage.test.tsx @@ -1,6 +1,5 @@ import React from "react"; import ReactTestRenderer from "react-test-renderer"; -import { expect } from "chai"; import ErrorMessage from "../../../src/console/components/ErrorMessage"; describe("console/components/console/completion/ErrorMessage", () => { @@ -11,7 +10,7 @@ describe("console/components/console/completion/ErrorMessage", () => { const p = root.findByType("p"); - expect(p.props["role"]).to.equal("alert"); - expect(p.children).to.deep.equal(["Hello!"]); + expect(p.props["role"]).toEqual("alert"); + expect(p.children).toEqual(["Hello!"]); }); }); diff --git a/test/console/components/InfoMessage.test.tsx b/test/console/components/InfoMessage.test.tsx index 1f8f16d..9f3a68d 100644 --- a/test/console/components/InfoMessage.test.tsx +++ b/test/console/components/InfoMessage.test.tsx @@ -1,6 +1,5 @@ import React from "react"; import ReactTestRenderer from "react-test-renderer"; -import { expect } from "chai"; import InfoMessage from "../../../src/console/components/InfoMessage"; describe("console/components/console/completion/InfoMessage", () => { @@ -11,7 +10,7 @@ describe("console/components/console/completion/InfoMessage", () => { const p = root.findByType("p"); - expect(p.props["role"]).to.equal("status"); - expect(p.children).to.deep.equal(["Hello!"]); + expect(p.props["role"]).toEqual("status"); + expect(p.children).toEqual(["Hello!"]); }); }); diff --git a/test/console/components/console/Completion.test.tsx b/test/console/components/console/Completion.test.tsx index 063b1e3..7dd634f 100644 --- a/test/console/components/console/Completion.test.tsx +++ b/test/console/components/console/Completion.test.tsx @@ -1,7 +1,6 @@ import React from "react"; import Completion from "../../../../src/console/components/console/Completion"; import ReactTestRenderer from "react-test-renderer"; -import { expect } from "chai"; import CompletionTitle from "../../../../src/console/components/console/CompletionTitle"; import CompletionItem from "../../../../src/console/components/console/CompletionItem"; @@ -31,16 +30,16 @@ describe("console/components/console/completion/Completion", () => { ).root; const groups = root.findAllByProps({ role: "group" }); - expect(groups).to.have.lengthOf(2); + expect(groups).toHaveLength(2); groups.forEach((group, i) => { const title = group.findByType(CompletionTitle); - expect(title.props.title).to.equal(completions[i].name); + expect(title.props.title).toEqual(completions[i].name); const items = group.findAllByType(CompletionItem); - expect(items).to.have.lengthOf(completions[i].items.length); + expect(items).toHaveLength(completions[i].items.length); items.forEach((item, j) => { - expect(item.props.caption).to.equal(completions[i].items[j].caption); + expect(item.props.caption).toEqual(completions[i].items[j].caption); }); }); }); @@ -51,7 +50,7 @@ describe("console/components/console/completion/Completion", () => { ).root; const items = root.findAllByType(CompletionItem); - expect(items[3].props.highlight).to.be.true; + expect(items[3].props.highlight).toBeTruthy; }); it("does not highlight any items", () => { @@ -60,7 +59,7 @@ describe("console/components/console/completion/Completion", () => { ).root; const items = root.findAllByType(CompletionItem); - expect(items.every((item) => item.props.highlight === false)).to.be.true; + expect(items.every((item) => item.props.highlight === false)).toBeTruthy; }); it("limits completion items", () => { @@ -78,7 +77,7 @@ describe("console/components/console/completion/Completion", () => { ) .flat(); - expect(showns).to.deep.equal([ + expect(showns).toEqual([ true, true, true, @@ -96,7 +95,7 @@ describe("console/components/console/completion/Completion", () => { const items = root .findAllByType(CompletionItem) .map((item) => item.props.shown); - expect(items[1]).to.be.true; + expect(items[1]).toBeTruthy; }); it("scrolls up to down with select", () => { @@ -120,7 +119,7 @@ describe("console/components/console/completion/Completion", () => { ].flat() ) .flat(); - expect(showns).to.deep.equal([ + expect(showns).toEqual([ true, true, true, @@ -146,7 +145,7 @@ describe("console/components/console/completion/Completion", () => { ].flat() ) .flat(); - expect(showns).to.deep.equal([ + expect(showns).toEqual([ false, true, true, @@ -156,7 +155,7 @@ describe("console/components/console/completion/Completion", () => { false, false, ]); - expect(items[2].props.highlight).to.be.true; + expect(items[2].props.highlight).toBeTruthy; ReactTestRenderer.act(() => { component!.update( @@ -173,7 +172,7 @@ describe("console/components/console/completion/Completion", () => { ].flat() ) .flat(); - expect(showns).to.deep.equal([ + expect(showns).toEqual([ false, false, false, @@ -183,7 +182,7 @@ describe("console/components/console/completion/Completion", () => { false, false, ]); - expect(items[3].props.highlight).to.be.true; + expect(items[3].props.highlight).toBeTruthy; }); it("scrolls down to up with select", () => { @@ -207,7 +206,7 @@ describe("console/components/console/completion/Completion", () => { ) .flat(); - expect(showns).to.deep.equal([ + expect(showns).toEqual([ false, false, false, @@ -217,7 +216,7 @@ describe("console/components/console/completion/Completion", () => { true, true, ]); - expect(items[5].props.highlight).to.be.true; + expect(items[5].props.highlight).toBeTruthy; ReactTestRenderer.act(() => { component!.update( @@ -234,7 +233,7 @@ describe("console/components/console/completion/Completion", () => { ].flat() ) .flat(); - expect(showns).to.deep.equal([ + expect(showns).toEqual([ false, false, false, @@ -244,7 +243,7 @@ describe("console/components/console/completion/Completion", () => { true, true, ]); - expect(items[4].props.highlight).to.be.true; + expect(items[4].props.highlight).toBeTruthy; ReactTestRenderer.act(() => { component!.update( @@ -261,7 +260,7 @@ describe("console/components/console/completion/Completion", () => { ].flat() ) .flat(); - expect(showns).to.deep.equal([ + expect(showns).toEqual([ false, false, false, @@ -271,7 +270,7 @@ describe("console/components/console/completion/Completion", () => { true, true, ]); - expect(items[3].props.highlight).to.be.true; + expect(items[3].props.highlight).toBeTruthy; ReactTestRenderer.act(() => { component!.update( @@ -288,7 +287,7 @@ describe("console/components/console/completion/Completion", () => { ].flat() ) .flat(); - expect(showns).to.deep.equal([ + expect(showns).toEqual([ false, false, false, @@ -298,6 +297,6 @@ describe("console/components/console/completion/Completion", () => { false, false, ]); - expect(items[2].props.highlight).to.be.true; + expect(items[2].props.highlight).toBeTruthy; }); }); diff --git a/test/console/components/console/CompletionItem.test.tsx b/test/console/components/console/CompletionItem.test.tsx index 3a4b1f2..ae73b21 100644 --- a/test/console/components/console/CompletionItem.test.tsx +++ b/test/console/components/console/CompletionItem.test.tsx @@ -1,6 +1,5 @@ import React from "react"; import ReactTestRenderer from "react-test-renderer"; -import { expect } from "chai"; import CompletionItem from "../../../../src/console/components/console/CompletionItem"; describe("console/components/console/completion/CompletionItem", () => { @@ -14,8 +13,8 @@ describe("console/components/console/completion/CompletionItem", () => { /> ).root; const spans = root.findAllByType("span"); - expect(spans).to.have.lengthOf(2); - expect(spans[0].children).to.deep.equal(["twitter"]); - expect(spans[1].children).to.deep.equal(["https://twitter.com/"]); + expect(spans).toHaveLength(2); + expect(spans[0].children).toEqual(["twitter"]); + expect(spans[1].children).toEqual(["https://twitter.com/"]); }); }); diff --git a/test/console/components/console/CompletionTitle.test.tsx b/test/console/components/console/CompletionTitle.test.tsx index d8cc411..5843c43 100644 --- a/test/console/components/console/CompletionTitle.test.tsx +++ b/test/console/components/console/CompletionTitle.test.tsx @@ -1,6 +1,5 @@ import React from "react"; import ReactTestRenderer from "react-test-renderer"; -import { expect } from "chai"; import CompletionTitle from "../../../../src/console/components/console/CompletionTitle"; describe("console/components/console/completion/CompletionTitle", () => { @@ -10,6 +9,6 @@ describe("console/components/console/completion/CompletionTitle", () => { ).root; const li = root.findByType("li"); - expect(li.children).to.deep.equal(["Fruits"]); + expect(li.children).toEqual(["Fruits"]); }); }); diff --git a/test/content/InputDriver.test.ts b/test/content/InputDriver.test.ts index b0dde77..9ab0965 100644 --- a/test/content/InputDriver.test.ts +++ b/test/content/InputDriver.test.ts @@ -5,7 +5,6 @@ import InputDriver, { keyFromKeyboardEvent, } from "../../src/content/InputDriver"; -import { expect } from "chai"; import Key from "../../src/shared/settings/Key"; describe("InputDriver", () => { @@ -24,11 +23,11 @@ describe("InputDriver", () => { it("register callbacks", (done) => { driver.onKey((key: Key): boolean => { - expect(key.key).to.equal("a"); - expect(key.ctrl).to.be.true; - expect(key.shift).to.be.false; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("a"); + expect(key.ctrl).toBeTruthy; + expect(key.shift).toBeFalsy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; done(); return true; }); @@ -69,8 +68,8 @@ describe("InputDriver", () => { target.dispatchEvent(e); } - expect(a).to.equal(1); - expect(b).to.equal(1); + expect(a).toEqual(1); + expect(b).toEqual(1); }); it("propagates and stop handler chain", () => { @@ -92,14 +91,14 @@ describe("InputDriver", () => { target.dispatchEvent(new KeyboardEvent("keydown", { key: "b" })); - expect(a).to.equal(1); - expect(b).to.equal(1); - expect(c).to.equal(0); + expect(a).toEqual(1); + expect(b).toEqual(1); + expect(c).toEqual(0); }); it("does not invoke only meta keys", () => { driver.onKey((_key: Key): boolean => { - expect.fail(); + throw new Error("unexpected reach"); return false; }); @@ -114,7 +113,7 @@ describe("InputDriver", () => { const input = window.document.createElement(name); const driver = new InputDriver(input); driver.onKey((_key: Key): boolean => { - expect.fail(); + throw new Error("unexpected reach"); return false; }); input.dispatchEvent(new KeyboardEvent("keydown", { key: "x" })); @@ -125,7 +124,7 @@ describe("InputDriver", () => { const div = window.document.createElement("div"); const driver = new InputDriver(div); driver.onKey((_key: Key): boolean => { - expect.fail(); + throw new Error("unexpected reach"); return false; }); @@ -148,11 +147,11 @@ describe("#keyFromKeyboardEvent", () => { metaKey: true, }) ); - expect(k.key).to.equal("x"); - expect(k.shift).to.be.false; - expect(k.ctrl).to.be.true; - expect(k.alt).to.be.false; - expect(k.meta).to.be.true; + expect(k.key).toEqual("x"); + expect(k.shift).toBeFalsy; + expect(k.ctrl).toBeTruthy; + expect(k.alt).toBeFalsy; + expect(k.meta).toBeTruthy; }); it("returns from keyboard input Shift+Esc", () => { @@ -165,11 +164,11 @@ describe("#keyFromKeyboardEvent", () => { metaKey: true, }) ); - expect(k.key).to.equal("Esc"); - expect(k.shift).to.be.true; - expect(k.ctrl).to.be.false; - expect(k.alt).to.be.false; - expect(k.meta).to.be.true; + expect(k.key).toEqual("Esc"); + expect(k.shift).toBeTruthy; + expect(k.ctrl).toBeFalsy; + expect(k.alt).toBeFalsy; + expect(k.meta).toBeTruthy; }); it("returns from keyboard input Ctrl+$", () => { @@ -183,11 +182,11 @@ describe("#keyFromKeyboardEvent", () => { metaKey: false, }) ); - expect(k.key).to.equal("$"); - expect(k.shift).to.be.false; - expect(k.ctrl).to.be.true; - expect(k.alt).to.be.false; - expect(k.meta).to.be.false; + expect(k.key).toEqual("$"); + expect(k.shift).toBeFalsy; + expect(k.ctrl).toBeTruthy; + expect(k.alt).toBeFalsy; + expect(k.meta).toBeFalsy; }); it("returns from keyboard input Crtl+Space", () => { @@ -200,10 +199,10 @@ describe("#keyFromKeyboardEvent", () => { metaKey: false, }) ); - expect(k.key).to.equal("Space"); - expect(k.shift).to.be.false; - expect(k.ctrl).to.be.true; - expect(k.alt).to.be.false; - expect(k.meta).to.be.false; + expect(k.key).toEqual("Space"); + expect(k.shift).toBeFalsy; + expect(k.ctrl).toBeTruthy; + expect(k.alt).toBeFalsy; + expect(k.meta).toBeFalsy; }); }); diff --git a/test/content/domains/KeySequence.test.ts b/test/content/domains/KeySequence.test.ts index 1d1debe..683f592 100644 --- a/test/content/domains/KeySequence.test.ts +++ b/test/content/domains/KeySequence.test.ts @@ -1,5 +1,4 @@ import KeySequence from "../../../src/content/domains/KeySequence"; -import { expect } from "chai"; import Key from "../../../src/shared/settings/Key"; describe("KeySequence", () => { @@ -9,9 +8,9 @@ describe("KeySequence", () => { seq.push(Key.fromMapKey("g")); seq.push(Key.fromMapKey("")); - expect(seq.keys[0].key).to.equal("g"); - expect(seq.keys[1].key).to.equal("U"); - expect(seq.keys[1].shift).to.be.true; + expect(seq.keys[0].key).toEqual("g"); + expect(seq.keys[1].key).toEqual("U"); + expect(seq.keys[1].shift).toBeTruthy; }); }); @@ -22,13 +21,13 @@ describe("KeySequence", () => { Key.fromMapKey(""), ]); - expect(seq.startsWith(new KeySequence([]))).to.be.true; - expect(seq.startsWith(new KeySequence([Key.fromMapKey("g")]))).to.be.true; + expect(seq.startsWith(new KeySequence([]))).toBeTruthy; + expect(seq.startsWith(new KeySequence([Key.fromMapKey("g")]))).toBeTruthy; expect( seq.startsWith( new KeySequence([Key.fromMapKey("g"), Key.fromMapKey("")]) ) - ).to.be.true; + ).toBeTruthy; expect( seq.startsWith( new KeySequence([ @@ -37,17 +36,15 @@ describe("KeySequence", () => { Key.fromMapKey("x"), ]) ) - ).to.be.false; - expect(seq.startsWith(new KeySequence([Key.fromMapKey("h")]))).to.be - .false; + ).toBeFalsy; + expect(seq.startsWith(new KeySequence([Key.fromMapKey("h")]))).toBeFalsy; }); it("returns true if the empty sequence starts with an empty sequence", () => { const seq = new KeySequence([]); - expect(seq.startsWith(new KeySequence([]))).to.be.true; - expect(seq.startsWith(new KeySequence([Key.fromMapKey("h")]))).to.be - .false; + expect(seq.startsWith(new KeySequence([]))).toBeTruthy; + expect(seq.startsWith(new KeySequence([Key.fromMapKey("h")]))).toBeFalsy; }); }); @@ -58,14 +55,14 @@ describe("KeySequence", () => { new Key({ key: "4" }), new Key({ key: "0" }), ]).isDigitOnly() - ).to.be.true; + ).toBeTruthy; expect( new KeySequence([ new Key({ key: "4" }), new Key({ key: "0" }), new Key({ key: "z" }), ]).isDigitOnly() - ).to.be.false; + ).toBeFalsy; }); }); @@ -77,7 +74,7 @@ describe("KeySequence", () => { new Key({ key: "g" }), new Key({ key: "g" }), ]); - expect(seq.repeatCount()).to.equal(10); + expect(seq.repeatCount()).toEqual(10); seq = new KeySequence([ new Key({ key: "0" }), @@ -85,23 +82,23 @@ describe("KeySequence", () => { new Key({ key: "g" }), new Key({ key: "g" }), ]); - expect(seq.repeatCount()).to.equal(5); + expect(seq.repeatCount()).toEqual(5); }); it("returns 1 if no numeric prefix", () => { let seq = new KeySequence([new Key({ key: "g" }), new Key({ key: "g" })]); - expect(seq.repeatCount()).to.equal(1); + expect(seq.repeatCount()).toEqual(1); seq = new KeySequence([]); - expect(seq.repeatCount()).to.equal(1); + expect(seq.repeatCount()).toEqual(1); }); it("returns whole keys if digits only sequence", () => { let seq = new KeySequence([new Key({ key: "1" }), new Key({ key: "0" })]); - expect(seq.repeatCount()).to.equal(10); + expect(seq.repeatCount()).toEqual(10); seq = new KeySequence([new Key({ key: "0" }), new Key({ key: "5" })]); - expect(seq.repeatCount()).to.equal(5); + expect(seq.repeatCount()).toEqual(5); }); }); @@ -114,7 +111,7 @@ describe("KeySequence", () => { new Key({ key: "g" }), new Key({ key: "3" }), ]).trimNumericPrefix(); - expect(seq.keys.map((key) => key.key)).to.deep.equal(["g", "g", "3"]); + expect(seq.keys.map((key) => key.key)).toEqual(["g", "g", "3"]); }); it("returns empty if keys contains only digis", () => { @@ -122,7 +119,7 @@ describe("KeySequence", () => { new Key({ key: "1" }), new Key({ key: "0" }), ]).trimNumericPrefix(); - expect(seq.trimNumericPrefix().keys).to.be.empty; + expect(seq.trimNumericPrefix().keys).toHaveLength(0); }); it("returns itself if no numeric prefix", () => { @@ -132,23 +129,21 @@ describe("KeySequence", () => { new Key({ key: "3" }), ]).trimNumericPrefix(); - expect(seq.keys.map((key) => key.key)).to.deep.equal(["g", "g", "3"]); + expect(seq.keys.map((key) => key.key)).toEqual(["g", "g", "3"]); }); }); describe("#splitNumericPrefix", () => { it("splits numeric prefix", () => { - expect( - KeySequence.fromMapKeys("10gg").splitNumericPrefix() - ).to.deep.equal([ + expect(KeySequence.fromMapKeys("10gg").splitNumericPrefix()).toEqual([ KeySequence.fromMapKeys("10"), KeySequence.fromMapKeys("gg"), ]); - expect(KeySequence.fromMapKeys("10").splitNumericPrefix()).to.deep.equal([ + expect(KeySequence.fromMapKeys("10").splitNumericPrefix()).toEqual([ KeySequence.fromMapKeys("10"), new KeySequence([]), ]); - expect(KeySequence.fromMapKeys("gg").splitNumericPrefix()).to.deep.equal([ + expect(KeySequence.fromMapKeys("gg").splitNumericPrefix()).toEqual([ new KeySequence([]), KeySequence.fromMapKeys("gg"), ]); @@ -158,22 +153,22 @@ describe("KeySequence", () => { describe("#fromMapKeys", () => { it("returns mapped keys for Shift+Esc", () => { const keys = KeySequence.fromMapKeys("").keys; - expect(keys).to.have.lengthOf(1); - expect(keys[0].key).to.equal("Esc"); - expect(keys[0].shift).to.be.true; + expect(keys).toHaveLength(1); + expect(keys[0].key).toEqual("Esc"); + expect(keys[0].shift).toBeTruthy; }); it("returns mapped keys for ad", () => { const keys = KeySequence.fromMapKeys("ad").keys; - expect(keys).to.have.lengthOf(5); - expect(keys[0].key).to.equal("a"); - expect(keys[1].ctrl).to.be.true; - expect(keys[1].key).to.equal("b"); - expect(keys[2].alt).to.be.true; - expect(keys[2].key).to.equal("c"); - expect(keys[3].key).to.equal("d"); - expect(keys[4].meta).to.be.true; - expect(keys[4].key).to.equal("e"); + expect(keys).toHaveLength(5); + expect(keys[0].key).toEqual("a"); + expect(keys[1].ctrl).toBeTruthy; + expect(keys[1].key).toEqual("b"); + expect(keys[2].alt).toBeTruthy; + expect(keys[2].key).toEqual("c"); + expect(keys[3].key).toEqual("d"); + expect(keys[4].meta).toBeTruthy; + expect(keys[4].key).toEqual("e"); }); }); }); diff --git a/test/content/operators/impls/AddonOperatorFactoryChain.test.ts b/test/content/operators/impls/AddonOperatorFactoryChain.test.ts index dde5a35..263104e 100644 --- a/test/content/operators/impls/AddonOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/AddonOperatorFactoryChain.test.ts @@ -3,7 +3,6 @@ import EnableAddonOperator from "../../../../src/content/operators/impls/EnableA import DisableAddonOperator from "../../../../src/content/operators/impls/DisableAddonOperator"; import ToggleAddonOperator from "../../../../src/content/operators/impls/ToggleAddonOperator"; import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient"; import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository"; import MockConsoleFramePresenter from "./MockConsoleFramePresenter"; @@ -16,16 +15,16 @@ describe("AddonOperatorFactoryChain", () => { new MockAddonEnabledRepository(), new MockConsoleFramePresenter(false) ); - expect(sut.create({ type: operations.ADDON_ENABLE }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.ADDON_ENABLE }, 0)).toBeInstanceOf( EnableAddonOperator ); - expect( - sut.create({ type: operations.ADDON_DISABLE }, 0) - ).to.be.instanceOf(DisableAddonOperator); + expect(sut.create({ type: operations.ADDON_DISABLE }, 0)).toBeInstanceOf( + DisableAddonOperator + ); expect( sut.create({ type: operations.ADDON_TOGGLE_ENABLED }, 0) - ).to.be.instanceOf(ToggleAddonOperator); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + ).toBeInstanceOf(ToggleAddonOperator); + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/BackgroundOperationOperator.test.ts b/test/content/operators/impls/BackgroundOperationOperator.test.ts index b8b1fbd..77efeb2 100644 --- a/test/content/operators/impls/BackgroundOperationOperator.test.ts +++ b/test/content/operators/impls/BackgroundOperationOperator.test.ts @@ -1,7 +1,6 @@ import * as operations from "../../../../src/shared/operations"; import BackgroundOperationOperator from "../../../../src/content/operators/impls/BackgroundOperationOperator"; import OperationClient from "../../../../src/content/client/OperationClient"; -import { expect } from "chai"; class MockOperationClient implements OperationClient { public readonly executedOps: { @@ -30,7 +29,7 @@ describe("BackgroundOperationOperator", () => { await sut.run(); - expect(client.executedOps).to.deep.equal([ + expect(client.executedOps).toEqual([ { op: { type: operations.TAB_CLOSE }, repeat: 2 }, ]); }); diff --git a/test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts b/test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts index 9ddc229..d4c61c4 100644 --- a/test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import ClipboardOperatorFactoryChain from "../../../../src/content/operators/impls/ClipboardOperatorFactoryChain"; import YankURLOperator from "../../../../src/content/operators/impls/YankURLOperator"; import PasteOperator from "../../../../src/content/operators/impls/PasteOperator"; @@ -19,13 +18,13 @@ describe("ClipboardOperatorFactoryChain", () => { new MockSettingRepository(), new MockURLRepository() ); - expect(sut.create({ type: operations.URLS_YANK }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.URLS_YANK }, 0)).toBeInstanceOf( YankURLOperator ); expect( sut.create({ type: operations.URLS_PASTE, newTab: false }, 0) - ).to.be.instanceOf(PasteOperator); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + ).toBeInstanceOf(PasteOperator); + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/DisableAddonOperator.test.ts b/test/content/operators/impls/DisableAddonOperator.test.ts index e05d1f1..bb137ac 100644 --- a/test/content/operators/impls/DisableAddonOperator.test.ts +++ b/test/content/operators/impls/DisableAddonOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import DisableAddonOperator from "../../../../src/content/operators/impls/DisableAddonOperator"; import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient"; import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository"; @@ -14,9 +13,9 @@ describe("DisableAddonOperator", () => { await sut.run(); - expect(client.enabled).to.be.false; - expect(repository.enabled).to.be.false; - expect(presenter.attached).to.be.false; + expect(client.enabled).toBeFalsy; + expect(repository.enabled).toBeFalsy; + expect(presenter.attached).toBeFalsy; }); }); }); diff --git a/test/content/operators/impls/EnableAddonOperator.test.ts b/test/content/operators/impls/EnableAddonOperator.test.ts index 6025608..cd838af 100644 --- a/test/content/operators/impls/EnableAddonOperator.test.ts +++ b/test/content/operators/impls/EnableAddonOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import EnableAddonOperator from "../../../../src/content/operators/impls/EnableAddonOperator"; import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient"; import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository"; @@ -14,9 +13,9 @@ describe("EnableAddonOperator", () => { await sut.run(); - expect(client.enabled).to.be.true; - expect(repository.enabled).to.be.true; - expect(presenter.attached).to.be.true; + expect(client.enabled).toBeTruthy; + expect(repository.enabled).toBeTruthy; + expect(presenter.attached).toBeTruthy; }); }); }); diff --git a/test/content/operators/impls/EnableJumpMarkOperator.test.ts b/test/content/operators/impls/EnableJumpMarkOperator.test.ts index 66b4ecd..f81d6dc 100644 --- a/test/content/operators/impls/EnableJumpMarkOperator.test.ts +++ b/test/content/operators/impls/EnableJumpMarkOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import EnableJumpMarkOperator from "../../../../src/content/operators/impls/EnableJumpMarkOperator"; import MockMarkKeyRepository from "../../mock/MockMarkKeyRepository"; @@ -13,7 +12,7 @@ describe("EnableJumpMarkOperator", () => { await sut.run(); - expect(repository.jumpMode).to.be.true; + expect(repository.jumpMode).toBeTruthy; }); }); }); diff --git a/test/content/operators/impls/EnableSetMarkOperator.test.ts b/test/content/operators/impls/EnableSetMarkOperator.test.ts index b28874d..33ce2ba 100644 --- a/test/content/operators/impls/EnableSetMarkOperator.test.ts +++ b/test/content/operators/impls/EnableSetMarkOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import EnableSetMarkOperator from "../../../../src/content/operators/impls/EnableSetMarkOperator"; import MockMarkKeyRepository from "../../mock/MockMarkKeyRepository"; @@ -13,7 +12,7 @@ describe("EnableSetMarkOperator", () => { await sut.run(); - expect(repository.setMode).to.be.true; + expect(repository.setMode).toBeTruthy; }); }); }); diff --git a/test/content/operators/impls/FocusOperatorFactoryChain.test.ts b/test/content/operators/impls/FocusOperatorFactoryChain.test.ts index 91f734b..84a4a52 100644 --- a/test/content/operators/impls/FocusOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/FocusOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import FocusOperatorFactoryChain from "../../../../src/content/operators/impls/FocusOperatorFactoryChain"; import FocusOperator from "../../../../src/content/operators/impls/FocusOperator"; import MockFocusPresenter from "../../mock/MockFocusPresenter"; @@ -8,10 +7,10 @@ describe("FocusOperatorFactoryChain", () => { describe("#create", () => { it("returns an operator", () => { const sut = new FocusOperatorFactoryChain(new MockFocusPresenter()); - expect(sut.create({ type: operations.FOCUS_INPUT }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.FOCUS_INPUT }, 0)).toBeInstanceOf( FocusOperator ); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/FollowOperatorFactoryChain.test.ts b/test/content/operators/impls/FollowOperatorFactoryChain.test.ts index 91f734b..84a4a52 100644 --- a/test/content/operators/impls/FollowOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/FollowOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import FocusOperatorFactoryChain from "../../../../src/content/operators/impls/FocusOperatorFactoryChain"; import FocusOperator from "../../../../src/content/operators/impls/FocusOperator"; import MockFocusPresenter from "../../mock/MockFocusPresenter"; @@ -8,10 +7,10 @@ describe("FocusOperatorFactoryChain", () => { describe("#create", () => { it("returns an operator", () => { const sut = new FocusOperatorFactoryChain(new MockFocusPresenter()); - expect(sut.create({ type: operations.FOCUS_INPUT }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.FOCUS_INPUT }, 0)).toBeInstanceOf( FocusOperator ); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/HorizontalScrollOperator.test.ts b/test/content/operators/impls/HorizontalScrollOperator.test.ts index f77a34e..abe6856 100644 --- a/test/content/operators/impls/HorizontalScrollOperator.test.ts +++ b/test/content/operators/impls/HorizontalScrollOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import HorizontalScrollOperator from "../../../../src/content/operators/impls/HorizontalScrollOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("HorizontalScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 1, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 1, y: 0 }); }); it("scroll horizontally with repeats", async () => { @@ -22,7 +21,7 @@ describe("HorizontalScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 5, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 5, y: 0 }); }); }); }); diff --git a/test/content/operators/impls/MarkOperatorFactoryChain.test.ts b/test/content/operators/impls/MarkOperatorFactoryChain.test.ts index 1f094dd..99cb756 100644 --- a/test/content/operators/impls/MarkOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/MarkOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import MarkOperatorFactoryChain from "../../../../src/content/operators/impls/MarkOperatorFactoryChain"; import MockMarkKeyRepository from "../../mock/MockMarkKeyRepository"; import EnableSetMarkOperator from "../../../../src/content/operators/impls/EnableSetMarkOperator"; @@ -11,11 +10,11 @@ describe("MarkOperatorFactoryChain", () => { const sut = new MarkOperatorFactoryChain(new MockMarkKeyRepository()); expect( sut.create({ type: operations.MARK_SET_PREFIX }, 0) - ).to.be.instanceOf(EnableSetMarkOperator); + ).toBeInstanceOf(EnableSetMarkOperator); expect( sut.create({ type: operations.MARK_JUMP_PREFIX }, 0) - ).to.be.instanceOf(EnableJumpMarkOperator); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + ).toBeInstanceOf(EnableJumpMarkOperator); + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/PageScrollOperator.test.ts b/test/content/operators/impls/PageScrollOperator.test.ts index 80c9185..77d3a0f 100644 --- a/test/content/operators/impls/PageScrollOperator.test.ts +++ b/test/content/operators/impls/PageScrollOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import PageScrollOperator from "../../../../src/content/operators/impls/PageScrollOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("PageScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 1, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 1, y: 0 }); }); it("scroll by a page with repeats", async () => { @@ -22,7 +21,7 @@ describe("PageScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 5, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 5, y: 0 }); }); }); }); diff --git a/test/content/operators/impls/ScrollOperatorFactoryChain.test.ts b/test/content/operators/impls/ScrollOperatorFactoryChain.test.ts index 08034cb..3ba204a 100644 --- a/test/content/operators/impls/ScrollOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/ScrollOperatorFactoryChain.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollOperatorFactoryChain from "../../../../src/content/operators/impls/ScrollOperatorFactoryChain"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -20,27 +19,27 @@ describe("ScrollOperatorFactoryChain", () => { ); expect( sut.create({ type: operations.SCROLL_HORIZONALLY, count: 10 }, 0) - ).to.be.instanceOf(HorizontalScrollOperator); + ).toBeInstanceOf(HorizontalScrollOperator); expect( sut.create({ type: operations.SCROLL_VERTICALLY, count: 10 }, 0) - ).to.be.instanceOf(VerticalScrollOperator); + ).toBeInstanceOf(VerticalScrollOperator); expect( sut.create({ type: operations.SCROLL_PAGES, count: 10 }, 0) - ).to.be.instanceOf(PageScrollOperator); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.instanceOf( + ).toBeInstanceOf(PageScrollOperator); + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeInstanceOf( ScrollToTopOperator ); - expect( - sut.create({ type: operations.SCROLL_BOTTOM }, 0) - ).to.be.instanceOf(ScrollToBottomOperator); - expect(sut.create({ type: operations.SCROLL_HOME }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.SCROLL_BOTTOM }, 0)).toBeInstanceOf( + ScrollToBottomOperator + ); + expect(sut.create({ type: operations.SCROLL_HOME }, 0)).toBeInstanceOf( ScrollToHomeOperator ); - expect(sut.create({ type: operations.SCROLL_END }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.SCROLL_END }, 0)).toBeInstanceOf( ScrollToEndOperator ); - expect(sut.create({ type: operations.PAGE_HOME, newTab: false }, 0)).to.be - .null; + expect(sut.create({ type: operations.PAGE_HOME, newTab: false }, 0)) + .toBeNull; }); }); }); diff --git a/test/content/operators/impls/ScrollToBottomOperator.test.ts b/test/content/operators/impls/ScrollToBottomOperator.test.ts index 500c8f2..f369227 100644 --- a/test/content/operators/impls/ScrollToBottomOperator.test.ts +++ b/test/content/operators/impls/ScrollToBottomOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollToBottomOperator from "../../../../src/content/operators/impls/ScrollToBottomOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("ScrollToBottomOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 0, y: Infinity }); + expect(presenter.getScroll()).toEqual({ x: 0, y: Infinity }); }); }); }); diff --git a/test/content/operators/impls/ScrollToEndOperator.test.ts b/test/content/operators/impls/ScrollToEndOperator.test.ts index 0c98c8d..304d914 100644 --- a/test/content/operators/impls/ScrollToEndOperator.test.ts +++ b/test/content/operators/impls/ScrollToEndOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollToEndOperator from "../../../../src/content/operators/impls/ScrollToEndOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("ScrollToEndOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: Infinity, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: Infinity, y: 0 }); }); }); }); diff --git a/test/content/operators/impls/ScrollToHomeOperator.test.ts b/test/content/operators/impls/ScrollToHomeOperator.test.ts index f8614d2..e09c16a 100644 --- a/test/content/operators/impls/ScrollToHomeOperator.test.ts +++ b/test/content/operators/impls/ScrollToHomeOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollToHomeOperator from "../../../../src/content/operators/impls/ScrollToHomeOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("ScrollToHomeOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 0, y: 10 }); + expect(presenter.getScroll()).toEqual({ x: 0, y: 10 }); }); }); }); diff --git a/test/content/operators/impls/ScrollToTopOperator.test.ts b/test/content/operators/impls/ScrollToTopOperator.test.ts index 25a84ba..7337bea 100644 --- a/test/content/operators/impls/ScrollToTopOperator.test.ts +++ b/test/content/operators/impls/ScrollToTopOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollToTopOperator from "../../../../src/content/operators/impls/ScrollToTopOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("ScrollToTopOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 10, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 10, y: 0 }); }); }); }); diff --git a/test/content/operators/impls/ToggleAddonOperator.test.ts b/test/content/operators/impls/ToggleAddonOperator.test.ts index 1f291b5..cc77429 100644 --- a/test/content/operators/impls/ToggleAddonOperator.test.ts +++ b/test/content/operators/impls/ToggleAddonOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ToggleAddonOperator from "../../../../src/content/operators/impls/ToggleAddonOperator"; import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient"; import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository"; @@ -14,15 +13,15 @@ describe("ToggleAddonOperator", () => { await sut.run(); - expect(client.enabled).to.be.false; - expect(repository.enabled).to.be.false; - expect(presenter.attached).to.be.false; + expect(client.enabled).toBeFalsy; + expect(repository.enabled).toBeFalsy; + expect(presenter.attached).toBeFalsy; await sut.run(); - expect(client.enabled).to.be.true; - expect(repository.enabled).to.be.true; - expect(presenter.attached).to.be.true; + expect(client.enabled).toBeTruthy; + expect(repository.enabled).toBeTruthy; + expect(presenter.attached).toBeTruthy; }); }); }); diff --git a/test/content/operators/impls/VerticalScrollOperator.test.ts b/test/content/operators/impls/VerticalScrollOperator.test.ts index 05b15d2..1b87060 100644 --- a/test/content/operators/impls/VerticalScrollOperator.test.ts +++ b/test/content/operators/impls/VerticalScrollOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import VerticalScrollOperator from "../../../../src/content/operators/impls/VerticalScrollOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("VerticalScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 0, y: 1 }); + expect(presenter.getScroll()).toEqual({ x: 0, y: 1 }); }); it("scroll vertically with repeats", async () => { @@ -22,7 +21,7 @@ describe("VerticalScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 0, y: 5 }); + expect(presenter.getScroll()).toEqual({ x: 0, y: 5 }); }); }); }); diff --git a/test/content/operators/impls/YankURLOperator.test.ts b/test/content/operators/impls/YankURLOperator.test.ts index 46e3d06..3db28bf 100644 --- a/test/content/operators/impls/YankURLOperator.test.ts +++ b/test/content/operators/impls/YankURLOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import MockClipboardRepository from "../../mock/MockClipboardRepository"; import YankURLOperator from "../../../../src/content/operators/impls/YankURLOperator"; import MockURLRepository from "../../mock/MockURLRepository"; @@ -18,9 +17,9 @@ describe("YankOperation", () => { await sut.run(); - expect(clipboardRepository.read()).to.equal("https://example.com/"); - expect(consoleClient.text).to.equal("Yanked https://example.com/"); - expect(consoleClient.isError).to.be.false; + expect(clipboardRepository.read()).toEqual("https://example.com/"); + expect(consoleClient.text).toEqual("Yanked https://example.com/"); + expect(consoleClient.isError).toBeFalsy; }); }); }); diff --git a/test/content/presenters/Hint.test.ts b/test/content/presenters/Hint.test.ts index 0823bdc..b3b2d19 100644 --- a/test/content/presenters/Hint.test.ts +++ b/test/content/presenters/Hint.test.ts @@ -6,7 +6,6 @@ import AbstractHint, { LinkHint, InputHint, } from "../../../src/content/presenters/Hint"; -import { expect } from "chai"; class Hint extends AbstractHint {} @@ -21,7 +20,7 @@ describe("Hint", () => { new Hint(link, "abc"); const elem = document.querySelector(".vimvixen-hint"); - expect(elem!.textContent!.trim()).to.be.equal("abc"); + expect(elem!.textContent!.trim()).toEqual("abc"); }); }); @@ -33,7 +32,7 @@ describe("Hint", () => { hint.show(); const elem = document.querySelector(".vimvixen-hint") as HTMLElement; - expect(elem.style.display).to.not.equal("none"); + expect(elem.style.display).not.toEqual("none"); }); }); @@ -44,7 +43,7 @@ describe("Hint", () => { hint.hide(); const elem = document.querySelector(".vimvixen-hint") as HTMLElement; - expect(elem.style.display).to.equal("none"); + expect(elem.style.display).toEqual("none"); }); }); @@ -54,9 +53,9 @@ describe("Hint", () => { const hint = new Hint(link, "abc"); const elem = document.querySelector(".vimvixen-hint")!; - expect(elem.parentElement).to.not.be.null; + expect(elem.parentElement).not.toBeNull; hint.remove(); - expect(elem.parentElement).to.be.null; + expect(elem.parentElement).toBeNull; }); }); }); @@ -75,7 +74,7 @@ describe("LinkHint", () => { const link = document.getElementById("test-link1") as HTMLAnchorElement; const hint = new LinkHint(link, "abc"); - expect(hint.getLink()).to.equal("https://google.com/"); + expect(hint.getLink()).toEqual("https://google.com/"); }); }); @@ -84,12 +83,12 @@ describe("LinkHint", () => { let link = document.getElementById("test-link1") as HTMLAnchorElement; let hint = new LinkHint(link, "abc"); - expect(hint.getLinkTarget()).to.be.null; + expect(hint.getLinkTarget()).toBeNull; link = document.getElementById("test-link2") as HTMLAnchorElement; hint = new LinkHint(link, "abc"); - expect(hint.getLinkTarget()).to.equal("_blank"); + expect(hint.getLinkTarget()).toEqual("_blank"); }); }); @@ -118,7 +117,7 @@ describe("InputHint", () => { const hint = new InputHint(input, "abc"); hint.activate(); - expect(document.activeElement).to.equal(input); + expect(document.activeElement).toEqual(input); }); }); @@ -132,7 +131,7 @@ describe("InputHint", () => { const hint = new InputHint(input, "abc"); hint.activate(); - expect(input.checked).to.be.true; + expect(input.checked).toBeTruthy; }); }); describe("