diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-09-26 17:01:31 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-09-26 17:23:14 +0900 |
commit | e304581fb15eabb3a973d363a282ee7546561e01 (patch) | |
tree | 1afb21a2dee2ada3d10c1417fa61c0aae1f83077 | |
parent | 11d6d725eee2ac0a1c16e4c7a4ce4f296bb6b016 (diff) |
Do not use chai on unit test
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("<S-U>")); - 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("<S-U>"), ]); - 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("<S-U>")]) ) - ).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("<S-Esc>").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 a<C-B><A-C>d<M-e>", () => { const keys = KeySequence.fromMapKeys("a<C-B><A-C>d<M-e>").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("<textarea>", () => { @@ -147,7 +146,7 @@ describe("InputHint", () => { const hint = new InputHint(textarea, "abc"); hint.activate(); - expect(document.activeElement).to.equal(textarea); + expect(document.activeElement).toEqual(textarea); }); }); diff --git a/test/content/presenters/NavigationPresenter.test.ts b/test/content/presenters/NavigationPresenter.test.ts index c377df4..0e51242 100644 --- a/test/content/presenters/NavigationPresenter.test.ts +++ b/test/content/presenters/NavigationPresenter.test.ts @@ -3,7 +3,6 @@ */ import { NavigationPresenterImpl } from "../../../src/content/presenters/NavigationPresenter"; -import { expect } from "chai"; describe("NavigationPresenterImpl", () => { let sut: NavigationPresenterImpl; @@ -14,7 +13,7 @@ describe("NavigationPresenterImpl", () => { document.body.innerHTML = html; method(); setTimeout(() => { - expect(document.location.hash).to.equal(`#${rel}`); + expect(document.location.hash).toEqual(`#${rel}`); done(); }, 0); }; diff --git a/test/content/repositories/AddonEnabledRepository.test.ts b/test/content/repositories/AddonEnabledRepository.test.ts index 13dff76..692407c 100644 --- a/test/content/repositories/AddonEnabledRepository.test.ts +++ b/test/content/repositories/AddonEnabledRepository.test.ts @@ -1,14 +1,13 @@ import { AddonEnabledRepositoryImpl } from "../../../src/content/repositories/AddonEnabledRepository"; -import { expect } from "chai"; describe("AddonEnabledRepositoryImpl", () => { it("updates and gets current value", () => { const sut = new AddonEnabledRepositoryImpl(); sut.set(true); - expect(sut.get()).to.be.true; + expect(sut.get()).toBeTruthy; sut.set(false); - expect(sut.get()).to.be.false; + expect(sut.get()).toBeFalsy; }); }); diff --git a/test/content/repositories/FollowKeyRepository.test.ts b/test/content/repositories/FollowKeyRepository.test.ts index cf1d3d5..fa35a54 100644 --- a/test/content/repositories/FollowKeyRepository.test.ts +++ b/test/content/repositories/FollowKeyRepository.test.ts @@ -1,7 +1,6 @@ import FollowKeyRepository, { FollowKeyRepositoryImpl, } from "../../../src/content/repositories/FollowKeyRepository"; -import { expect } from "chai"; describe("FollowKeyRepositoryImpl", () => { let sut: FollowKeyRepository; @@ -12,18 +11,18 @@ describe("FollowKeyRepositoryImpl", () => { describe("#getKeys()/#pushKey()/#popKey()", () => { it("enqueues keys", () => { - expect(sut.getKeys()).to.be.empty; + expect(sut.getKeys()).toHaveLength(0); sut.pushKey("a"); sut.pushKey("b"); sut.pushKey("c"); - expect(sut.getKeys()).to.deep.equal(["a", "b", "c"]); + expect(sut.getKeys()).toEqual(["a", "b", "c"]); sut.popKey(); - expect(sut.getKeys()).to.deep.equal(["a", "b"]); + expect(sut.getKeys()).toEqual(["a", "b"]); sut.clearKeys(); - expect(sut.getKeys()).to.be.empty; + expect(sut.getKeys()).toHaveLength(0); }); }); }); diff --git a/test/content/repositories/FollowMasterRepository.test.ts b/test/content/repositories/FollowMasterRepository.test.ts index 8e1d59e..6a7d0ac 100644 --- a/test/content/repositories/FollowMasterRepository.test.ts +++ b/test/content/repositories/FollowMasterRepository.test.ts @@ -1,7 +1,6 @@ import FollowMasterRepository, { FollowMasterRepositoryImpl, } from "../../../src/content/repositories/FollowMasterRepository"; -import { expect } from "chai"; describe("FollowMasterRepositoryImpl", () => { let sut: FollowMasterRepository; @@ -12,15 +11,15 @@ describe("FollowMasterRepositoryImpl", () => { describe("#getTags()/#addTag()/#clearTags()", () => { it("gets, adds and clears tags", () => { - expect(sut.getTags()).to.be.empty; + expect(sut.getTags()).toHaveLength(0); sut.addTag("a"); sut.addTag("b"); sut.addTag("c"); - expect(sut.getTags()).to.deep.equal(["a", "b", "c"]); + expect(sut.getTags()).toEqual(["a", "b", "c"]); sut.clearTags(); - expect(sut.getTags()).to.be.empty; + expect(sut.getTags()).toHaveLength(0); }); }); @@ -29,22 +28,22 @@ describe("FollowMasterRepositoryImpl", () => { for (const tag of ["a", "aa", "ab", "b", "ba", "bb"]) { sut.addTag(tag); } - expect(sut.getTagsByPrefix("a")).to.deep.equal(["a", "aa", "ab"]); - expect(sut.getTagsByPrefix("aa")).to.deep.equal(["aa"]); - expect(sut.getTagsByPrefix("b")).to.deep.equal(["b", "ba", "bb"]); - expect(sut.getTagsByPrefix("c")).to.be.empty; + expect(sut.getTagsByPrefix("a")).toEqual(["a", "aa", "ab"]); + expect(sut.getTagsByPrefix("aa")).toEqual(["aa"]); + expect(sut.getTagsByPrefix("b")).toEqual(["b", "ba", "bb"]); + expect(sut.getTagsByPrefix("c")).toHaveLength(0); }); }); describe("#setCurrentFollowMode()/#getCurrentNewTabMode()/#getCurrentBackgroundMode", () => { it("updates and gets follow mode", () => { sut.setCurrentFollowMode(false, true); - expect(sut.getCurrentNewTabMode()).to.be.false; - expect(sut.getCurrentBackgroundMode()).to.be.true; + expect(sut.getCurrentNewTabMode()).toBeFalsy; + expect(sut.getCurrentBackgroundMode()).toBeTruthy; sut.setCurrentFollowMode(true, false); - expect(sut.getCurrentNewTabMode()).to.be.true; - expect(sut.getCurrentBackgroundMode()).to.be.false; + expect(sut.getCurrentNewTabMode()).toBeTruthy; + expect(sut.getCurrentBackgroundMode()).toBeFalsy; }); }); }); diff --git a/test/content/repositories/FollowSlaveRepository.test.ts b/test/content/repositories/FollowSlaveRepository.test.ts index c19513d..52ed3fc 100644 --- a/test/content/repositories/FollowSlaveRepository.test.ts +++ b/test/content/repositories/FollowSlaveRepository.test.ts @@ -1,7 +1,6 @@ import FollowSlaveRepository, { FollowSlaveRepositoryImpl, } from "../../../src/content/repositories/FollowSlaveRepository"; -import { expect } from "chai"; describe("FollowSlaveRepository", () => { let sut: FollowSlaveRepository; @@ -12,13 +11,13 @@ describe("FollowSlaveRepository", () => { describe("#isFollowMode()/#enableFollowMode()/#disableFollowMode()", () => { it("gets, adds updates follow mode", () => { - expect(sut.isFollowMode()).to.be.false; + expect(sut.isFollowMode()).toBeFalsy; sut.enableFollowMode(); - expect(sut.isFollowMode()).to.be.true; + expect(sut.isFollowMode()).toBeTruthy; sut.disableFollowMode(); - expect(sut.isFollowMode()).to.be.false; + expect(sut.isFollowMode()).toBeFalsy; }); }); }); diff --git a/test/content/repositories/KeymapRepository.test.ts b/test/content/repositories/KeymapRepository.test.ts index 7321548..715187b 100644 --- a/test/content/repositories/KeymapRepository.test.ts +++ b/test/content/repositories/KeymapRepository.test.ts @@ -1,7 +1,6 @@ import KeymapRepository, { KeymapRepositoryImpl, } from "../../../src/content/repositories/KeymapRepository"; -import { expect } from "chai"; import Key from "../../../src/shared/settings/Key"; describe("KeymapRepositoryImpl", () => { @@ -18,9 +17,9 @@ describe("KeymapRepositoryImpl", () => { const sequence = sut.enqueueKey(Key.fromMapKey("c")); const keys = sequence.keys; - expect(keys[0].equals(Key.fromMapKey("a"))).to.be.true; - expect(keys[1].equals(Key.fromMapKey("b"))).to.be.true; - expect(keys[2].equals(Key.fromMapKey("c"))).to.be.true; + expect(keys[0].equals(Key.fromMapKey("a"))).toBeTruthy; + expect(keys[1].equals(Key.fromMapKey("b"))).toBeTruthy; + expect(keys[2].equals(Key.fromMapKey("c"))).toBeTruthy; }); }); @@ -32,7 +31,7 @@ describe("KeymapRepositoryImpl", () => { sut.clear(); const sequence = sut.enqueueKey(Key.fromMapKey("a")); - expect(sequence.length()).to.equal(1); + expect(sequence.length()).toEqual(1); }); }); }); diff --git a/test/content/repositories/MarkKeyRepository.test.ts b/test/content/repositories/MarkKeyRepository.test.ts index 317bbaa..a722a9c 100644 --- a/test/content/repositories/MarkKeyRepository.test.ts +++ b/test/content/repositories/MarkKeyRepository.test.ts @@ -1,7 +1,6 @@ import MarkRepository, { MarkKeyRepositoryImpl, } from "../../../src/content/repositories/MarkKeyRepository"; -import { expect } from "chai"; describe("MarkKeyRepositoryImpl", () => { let sut: MarkRepository; @@ -12,25 +11,25 @@ describe("MarkKeyRepositoryImpl", () => { describe("#isSetMode/#enableSetMode/#disabeSetMode", () => { it("enables and disables set mode", () => { - expect(sut.isSetMode()).to.be.false; + expect(sut.isSetMode()).toBeFalsy; sut.enableSetMode(); - expect(sut.isSetMode()).to.be.true; + expect(sut.isSetMode()).toBeTruthy; sut.disabeSetMode(); - expect(sut.isSetMode()).to.be.false; + expect(sut.isSetMode()).toBeFalsy; }); }); describe("#isJumpMode/#enableJumpMode/#disabeJumpMode", () => { it("enables and disables jump mode", () => { - expect(sut.isJumpMode()).to.be.false; + expect(sut.isJumpMode()).toBeFalsy; sut.enableJumpMode(); - expect(sut.isJumpMode()).to.be.true; + expect(sut.isJumpMode()).toBeTruthy; sut.disabeJumpMode(); - expect(sut.isJumpMode()).to.be.false; + expect(sut.isJumpMode()).toBeFalsy; }); }); }); diff --git a/test/content/repositories/MarkRepository.test.ts b/test/content/repositories/MarkRepository.test.ts index f2a7326..b4486a1 100644 --- a/test/content/repositories/MarkRepository.test.ts +++ b/test/content/repositories/MarkRepository.test.ts @@ -1,12 +1,11 @@ import { MarkRepositoryImpl } from "../../../src/content/repositories/MarkRepository"; -import { expect } from "chai"; describe("MarkRepositoryImpl", () => { it("save and load marks", () => { const sut = new MarkRepositoryImpl(); sut.set("a", { x: 10, y: 20 }); - expect(sut.get("a")).to.deep.equal({ x: 10, y: 20 }); - expect(sut.get("b")).to.be.null; + expect(sut.get("a")).toEqual({ x: 10, y: 20 }); + expect(sut.get("b")).toBeNull; }); }); diff --git a/test/content/repositories/SettingRepository.test.ts b/test/content/repositories/SettingRepository.test.ts index 99247a9..409012a 100644 --- a/test/content/repositories/SettingRepository.test.ts +++ b/test/content/repositories/SettingRepository.test.ts @@ -1,5 +1,4 @@ import { SettingRepositoryImpl } from "../../../src/content/repositories/SettingRepository"; -import { expect } from "chai"; import Settings from "../../../src/shared/settings/Settings"; describe("SettingRepositoryImpl", () => { @@ -25,6 +24,6 @@ describe("SettingRepositoryImpl", () => { sut.set(settings); const actual = sut.get(); - expect(actual.properties.hintchars).to.equal("abcd1234"); + expect(actual.properties.hintchars).toEqual("abcd1234"); }); }); diff --git a/test/content/usecases/AddonEnabledUseCase.test.ts b/test/content/usecases/AddonEnabledUseCase.test.ts index ee5f1cd..3d4d667 100644 --- a/test/content/usecases/AddonEnabledUseCase.test.ts +++ b/test/content/usecases/AddonEnabledUseCase.test.ts @@ -1,7 +1,6 @@ import AddonEnabledRepository from "../../../src/content/repositories/AddonEnabledRepository"; import AddonEnabledUseCase from "../../../src/content/usecases/AddonEnabledUseCase"; import AddonIndicatorClient from "../../../src/content/client/AddonIndicatorClient"; -import { expect } from "chai"; import MockConsoleFramePresenter from "../operators/impls/MockConsoleFramePresenter"; class MockAddonEnabledRepository implements AddonEnabledRepository { @@ -50,9 +49,9 @@ describe("AddonEnabledUseCase", () => { it("store and indicate as enabled", async () => { await sut.enable(); - expect(repository.get()).to.be.true; - expect(indicator.enabled).to.be.true; - expect(presenter.attached).to.be.true; + expect(repository.get()).toBeTruthy; + expect(indicator.enabled).toBeTruthy; + expect(presenter.attached).toBeTruthy; }); }); @@ -60,9 +59,9 @@ describe("AddonEnabledUseCase", () => { it("store and indicate as disabled", async () => { await sut.disable(); - expect(repository.get()).to.be.false; - expect(indicator.enabled).to.be.false; - expect(presenter.attached).to.be.false; + expect(repository.get()).toBeFalsy; + expect(indicator.enabled).toBeFalsy; + expect(presenter.attached).toBeFalsy; }); }); @@ -71,27 +70,27 @@ describe("AddonEnabledUseCase", () => { repository.set(true); await sut.toggle(); - expect(repository.get()).to.be.false; - expect(indicator.enabled).to.be.false; - expect(presenter.attached).to.be.false; + expect(repository.get()).toBeFalsy; + expect(indicator.enabled).toBeFalsy; + expect(presenter.attached).toBeFalsy; repository.set(false); await sut.toggle(); - expect(repository.get()).to.be.true; - expect(indicator.enabled).to.be.true; - expect(presenter.attached).to.be.true; + expect(repository.get()).toBeTruthy; + expect(indicator.enabled).toBeTruthy; + expect(presenter.attached).toBeTruthy; }); }); describe("#getEnabled", () => { it("returns current addon enabled", () => { repository.set(true); - expect(sut.getEnabled()).to.be.true; + expect(sut.getEnabled()).toBeTruthy; repository.set(false); - expect(sut.getEnabled()).to.be.false; + expect(sut.getEnabled()).toBeFalsy; }); }); }); diff --git a/test/content/usecases/HintKeyProducer.test.ts b/test/content/usecases/HintKeyProducer.test.ts index 9d320b4..a4ad4de 100644 --- a/test/content/usecases/HintKeyProducer.test.ts +++ b/test/content/usecases/HintKeyProducer.test.ts @@ -1,5 +1,4 @@ import { HintKeyRepositoryImpl } from "../../../src/content/repositories/HintKeyRepository"; -import { expect } from "chai"; describe("HintKeyProducerImpl class", () => { describe("#produce", () => { @@ -27,7 +26,7 @@ describe("HintKeyProducerImpl class", () => { const sut = new HintKeyRepositoryImpl(); sut.reset(charset); for (let i = 0; i < sequences.length; ++i) { - expect(sut.produce()).to.equal(sequences[i]); + expect(sut.produce()).toEqual(sequences[i]); } }); }); @@ -37,16 +36,16 @@ describe("HintKeyProducerImpl class", () => { const sut = new HintKeyRepositoryImpl(); sut.reset("ab"); - expect(sut.produce()).to.equal("a"); - expect(sut.produce()).to.equal("b"); + expect(sut.produce()).toEqual("a"); + expect(sut.produce()).toEqual("b"); sut.reset("xy"); - expect(sut.produce()).to.equal("x"); - expect(sut.produce()).to.equal("y"); + expect(sut.produce()).toEqual("x"); + expect(sut.produce()).toEqual("y"); }); it("throws an exception on empty charset", () => { const sut = new HintKeyRepositoryImpl(); - expect(() => sut.reset("")).to.throw(TypeError); + expect(() => sut.reset("")).toThrow(TypeError); }); }); }); diff --git a/test/content/usecases/KeymapUseCase.test.ts b/test/content/usecases/KeymapUseCase.test.ts index 22b09ac..7af3ab2 100644 --- a/test/content/usecases/KeymapUseCase.test.ts +++ b/test/content/usecases/KeymapUseCase.test.ts @@ -1,6 +1,5 @@ import "reflect-metadata"; import KeymapUseCase from "../../../src/content/usecases/KeymapUseCase"; -import { expect } from "chai"; import SettingRepository from "../../../src/content/repositories/SettingRepository"; import Settings from "../../../src/shared/settings/Settings"; import AddonEnabledRepository from "../../../src/content/repositories/AddonEnabledRepository"; @@ -62,27 +61,27 @@ describe("KeymapUseCase", () => { }); it("returns matched operation", () => { - expect(sut.nextOps(Key.fromMapKey("k"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("k"))).toEqual({ repeat: 1, op: { type: "scroll.vertically", count: -1 }, }); - expect(sut.nextOps(Key.fromMapKey("j"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("j"))).toEqual({ repeat: 1, op: { type: "scroll.vertically", count: 1 }, }); - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toEqual({ repeat: 1, op: { type: "scroll.top" }, }); - expect(sut.nextOps(Key.fromMapKey("z"))).to.be.null; + expect(sut.nextOps(Key.fromMapKey("z"))).toBeNull; }); it("repeats n-times by numeric prefix and multiple key operations", () => { - expect(sut.nextOps(Key.fromMapKey("1"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("0"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("1"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("0"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toEqual({ repeat: 10, op: { type: "scroll.top" }, }); @@ -109,36 +108,36 @@ describe("KeymapUseCase", () => { }); it("returns the matched operation ends with digit", () => { - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("5"))).to.be.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("5"))).toEqual({ repeat: 1, op: { type: "scroll.bottom" }, }); }); it("returns an operation matched the operation with digit keymaps", () => { - expect(sut.nextOps(Key.fromMapKey("2"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("0"))).to.be.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("2"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("0"))).toEqual({ repeat: 1, op: { type: "scroll.top" }, }); }); it("returns operations repeated by numeric prefix", () => { - expect(sut.nextOps(Key.fromMapKey("2"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("5"))).to.be.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("2"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("5"))).toEqual({ repeat: 2, op: { type: "scroll.bottom" }, }); }); it("does not matches with digit operation with numeric prefix", () => { - expect(sut.nextOps(Key.fromMapKey("3"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("2"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("0"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("5"))).to.be.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("3"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("2"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("0"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("5"))).toEqual({ repeat: 320, op: { type: "scroll.bottom" }, }); @@ -165,24 +164,24 @@ describe("KeymapUseCase", () => { }); it("clears input keys with no-matched operations", () => { - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("x"))).to.be.null; // clear - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("x"))).toBeNull; // clear + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toEqual({ repeat: 1, op: { type: "scroll.top" }, }); }); it("clears input keys and the prefix with no-matched operations", () => { - expect(sut.nextOps(Key.fromMapKey("1"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("0"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("x"))).to.be.null; // clear - expect(sut.nextOps(Key.fromMapKey("1"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("0"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("1"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("0"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("x"))).toBeNull; // clear + expect(sut.nextOps(Key.fromMapKey("1"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("0"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toEqual({ repeat: 10, op: { type: "scroll.top" }, }); @@ -210,12 +209,12 @@ describe("KeymapUseCase", () => { }); it("returns only ADDON_ENABLE and ADDON_TOGGLE_ENABLED operation", () => { - expect(sut.nextOps(Key.fromMapKey("k"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("a"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("k"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("a"))).toEqual({ repeat: 1, op: { type: "addon.enable" }, }); - expect(sut.nextOps(Key.fromMapKey("b"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("b"))).toEqual({ repeat: 1, op: { type: "addon.toggle.enabled" }, }); @@ -244,17 +243,17 @@ describe("KeymapUseCase", () => { new MockAddressRepository(new URL("https://example.com")) ); - expect(sut.nextOps(Key.fromMapKey("k"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("k"))).toEqual({ repeat: 1, op: { type: "scroll.vertically", count: -1 }, }); - expect(sut.nextOps(Key.fromMapKey("j"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("j"))).toEqual({ repeat: 1, op: { type: "scroll.vertically", count: 1 }, }); - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("G"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("G"))).toEqual({ repeat: 1, op: { type: "scroll.bottom" }, }); @@ -266,12 +265,12 @@ describe("KeymapUseCase", () => { new MockAddressRepository(new URL("https://example.org")) ); - expect(sut.nextOps(Key.fromMapKey("g"))).to.be.null; - expect(sut.nextOps(Key.fromMapKey("g"))).to.deep.equal({ + expect(sut.nextOps(Key.fromMapKey("g"))).toBeNull; + expect(sut.nextOps(Key.fromMapKey("g"))).toEqual({ repeat: 1, op: { type: "scroll.top" }, }); - expect(sut.nextOps(Key.fromMapKey("G"))).to.be.null; + expect(sut.nextOps(Key.fromMapKey("G"))).toBeNull; }); }); }); diff --git a/test/content/usecases/MarkUseCase.test.ts b/test/content/usecases/MarkUseCase.test.ts index df3f7bf..b788c3c 100644 --- a/test/content/usecases/MarkUseCase.test.ts +++ b/test/content/usecases/MarkUseCase.test.ts @@ -5,7 +5,6 @@ import MarkClient from "../../../src/content/client/MarkClient"; import MockConsoleClient from "../mock/MockConsoleClient"; import MockScrollPresenter from "../mock/MockScrollPresenter"; import Mark from "../../../src/content/domains/Mark"; -import { expect } from "chai"; class MockMarkRepository implements MarkRepository { private current: { [key: string]: Mark }; @@ -70,8 +69,8 @@ describe("MarkUseCase", () => { await sut.set("x"); - expect(repository.get("x")).to.deep.equals({ x: 10, y: 20 }); - expect(consoleClient.text).to.equal("Set local mark to 'x'"); + expect(repository.get("x")).toEqual({ x: 10, y: 20 }); + expect(consoleClient.text).toEqual("Set local mark to 'x'"); }); it("sets global mark", async () => { @@ -79,8 +78,8 @@ describe("MarkUseCase", () => { await sut.set("Z"); - expect(client.marks["Z"]).to.deep.equals({ x: 30, y: 40 }); - expect(consoleClient.text).to.equal("Set global mark to 'Z'"); + expect(client.marks["Z"]).toEqual({ x: 30, y: 40 }); + expect(consoleClient.text).toEqual("Set global mark to 'Z'"); }); }); @@ -90,7 +89,7 @@ describe("MarkUseCase", () => { await sut.jump("x"); - expect(scrollPresenter.getScroll()).to.deep.equals({ x: 20, y: 40 }); + expect(scrollPresenter.getScroll()).toEqual({ x: 20, y: 40 }); }); it("throws an error when no local marks", () => { @@ -100,7 +99,7 @@ describe("MarkUseCase", () => { throw new Error("error"); }) .catch((e) => { - expect(e).to.be.instanceof(Error); + expect(e).toBeInstanceOf(Error); }); }); @@ -109,7 +108,7 @@ describe("MarkUseCase", () => { await sut.jump("Z"); - expect(client.last).to.equal("Z"); + expect(client.last).toEqual("Z"); }); }); }); diff --git a/test/content/usecases/SettingUseCaase.test.ts b/test/content/usecases/SettingUseCaase.test.ts index 1cc1e8a..8339bd9 100644 --- a/test/content/usecases/SettingUseCaase.test.ts +++ b/test/content/usecases/SettingUseCaase.test.ts @@ -4,7 +4,6 @@ import SettingUseCase from "../../../src/content/usecases/SettingUseCase"; import Settings, { DefaultSetting, } from "../../../src/shared/settings/Settings"; -import { expect } from "chai"; class MockSettingRepository implements SettingRepository { private current: Settings; @@ -64,10 +63,10 @@ describe("AddonEnabledUseCase", () => { describe("#reload", () => { it("loads settings and store to repository", async () => { const settings = await sut.reload(); - expect(settings.properties.hintchars).to.equal("abcd1234"); + expect(settings.properties.hintchars).toEqual("abcd1234"); const saved = repository.get(); - expect(saved.properties.hintchars).to.equal("abcd1234"); + expect(saved.properties.hintchars).toEqual("abcd1234"); }); }); }); diff --git a/test/settings/components/form/BlacklistForm.test.tsx b/test/settings/components/form/BlacklistForm.test.tsx index 9840856..bd1a1e8 100644 --- a/test/settings/components/form/BlacklistForm.test.tsx +++ b/test/settings/components/form/BlacklistForm.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import ReactDOM from "react-dom"; import ReactTestRenderer from "react-test-renderer"; import ReactTestUtils from "react-dom/test-utils"; -import { expect } from "chai"; import BlacklistForm from "../../../../src/settings/components/form/BlacklistForm"; import Blacklist from "../../../../src/shared/settings/Blacklist"; @@ -24,15 +23,15 @@ describe("settings/form/BlacklistForm", () => { const rows = root .findAllByType("div") .filter((instance) => instance.props.role === "listitem"); - expect(rows).to.have.lengthOf(2); - expect(rows[0].findByProps({ name: "url" }).props.value).to.equal( + expect(rows).toHaveLength(2); + expect(rows[0].findByProps({ name: "url" }).props.value).toEqual( "*.slack.com" ); - expect(rows[1].findByProps({ name: "url" }).props.value).to.equal( + expect(rows[1].findByProps({ name: "url" }).props.value).toEqual( "www.google.com/maps" ); - expect(() => root.findByType(AddButton)).not.throw(); + expect(() => root.findByType(AddButton)).not.toThrow(); }); it("renders blank value", () => { @@ -41,7 +40,7 @@ describe("settings/form/BlacklistForm", () => { const rows = root.findAllByProps({ className: "form-blacklist-form-row", }); - expect(rows).to.be.empty; + expect(rows).toHaveLength(0); }); }); @@ -64,10 +63,7 @@ describe("settings/form/BlacklistForm", () => { value={Blacklist.fromJSON(["*.slack.com", "www.google.com/maps*"])} onChange={(value) => { const urls = value.items.map((item) => item.pattern); - expect(urls).to.have.members([ - "gitter.im", - "www.google.com/maps*", - ]); + expect(urls).toEqual(["gitter.im", "www.google.com/maps*"]); done(); }} />, @@ -89,7 +85,7 @@ describe("settings/form/BlacklistForm", () => { value={Blacklist.fromJSON(["*.slack.com", "www.google.com/maps*"])} onChange={(value) => { const urls = value.items.map((item) => item.pattern); - expect(urls).to.have.members(["www.google.com/maps*"]); + expect(urls).toEqual(["www.google.com/maps*"]); done(); }} />, @@ -108,7 +104,7 @@ describe("settings/form/BlacklistForm", () => { value={Blacklist.fromJSON(["*.slack.com"])} onChange={(value) => { const urls = value.items.map((item) => item.pattern); - expect(urls).to.have.members(["*.slack.com", ""]); + expect(urls).toEqual(["*.slack.com", ""]); done(); }} />, diff --git a/test/settings/components/form/KeymapsForm.test.tsx b/test/settings/components/form/KeymapsForm.test.tsx index 8bdbeb4..4701a96 100644 --- a/test/settings/components/form/KeymapsForm.test.tsx +++ b/test/settings/components/form/KeymapsForm.test.tsx @@ -8,7 +8,6 @@ import ReactTestRenderer from "react-test-renderer"; import ReactTestUtils from "react-dom/test-utils"; import KeymapsForm from "../../../../src/settings/components/form/KeymapsForm"; import { FormKeymaps } from "../../../../src/shared/SettingData"; -import { expect } from "chai"; describe("settings/form/KeymapsForm", () => { describe("render", () => { @@ -25,8 +24,8 @@ describe("settings/form/KeymapsForm", () => { const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); - expect(inputj.props.value).to.equal("j"); - expect(inputk.props.value).to.equal("k"); + expect(inputj.props.value).toEqual("j"); + expect(inputk.props.value).toEqual("k"); }); it("renders blank value", () => { @@ -35,8 +34,8 @@ describe("settings/form/KeymapsForm", () => { const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); - expect(inputj.props.value).to.be.empty; - expect(inputk.props.value).to.be.empty; + expect(inputj.props.value).toHaveLength(0); + expect(inputk.props.value).toHaveLength(0); }); }); @@ -61,7 +60,7 @@ describe("settings/form/KeymapsForm", () => { 'scroll.vertically?{"count":-1}': "k", })} onChange={(value) => { - expect(value.toJSON()['scroll.vertically?{"count":1}']).to.equal( + expect(value.toJSON()['scroll.vertically?{"count":1}']).toEqual( "jjj" ); done(); diff --git a/test/settings/components/form/PropertiesForm.test.tsx b/test/settings/components/form/PropertiesForm.test.tsx index df8f95e..0b481ab 100644 --- a/test/settings/components/form/PropertiesForm.test.tsx +++ b/test/settings/components/form/PropertiesForm.test.tsx @@ -7,7 +7,6 @@ import ReactDOM from "react-dom"; import ReactTestRenderer from "react-test-renderer"; import ReactTestUtils from "react-dom/test-utils"; import PropertiesForm from "../../../../src/settings/components/form/PropertiesForm"; -import { expect } from "chai"; describe("settings/form/PropertiesForm", () => { describe("render", () => { @@ -29,16 +28,16 @@ describe("settings/form/PropertiesForm", () => { ).root; let input = root.findByProps({ name: "mystr" }); - expect(input.props.type).to.equals("text"); - expect(input.props.value).to.equal("abc"); + expect(input.props.type).toEqual("text"); + expect(input.props.value).toEqual("abc"); input = root.findByProps({ name: "mynum" }); - expect(input.props.type).to.equals("number"); - expect(input.props.value).to.equal(123); + expect(input.props.type).toEqual("number"); + expect(input.props.value).toEqual(123); input = root.findByProps({ name: "mybool" }); - expect(input.props.type).to.equals("checkbox"); - expect(input.props.value).to.equal(true); + expect(input.props.type).toEqual("checkbox"); + expect(input.props.value).toEqual(true); }); }); @@ -61,7 +60,7 @@ describe("settings/form/PropertiesForm", () => { types={{ myvalue: "string" }} value={{ myvalue: "abc" }} onChange={(value) => { - expect(value).to.have.property("myvalue", "abcd"); + expect(value).toHaveProperty("myvalue", "abcd"); done(); }} />, @@ -83,7 +82,7 @@ describe("settings/form/PropertiesForm", () => { types={{ myvalue: "number" }} value={{ "": 123 }} onChange={(value) => { - expect(value).to.have.property("myvalue", 1234); + expect(value).toHaveProperty("myvalue", 1234); done(); }} />, @@ -105,7 +104,7 @@ describe("settings/form/PropertiesForm", () => { types={{ myvalue: "boolean" }} value={{ myvalue: false }} onChange={(value) => { - expect(value).to.have.property("myvalue", true); + expect(value).toHaveProperty("myvalue", true); done(); }} />, diff --git a/test/settings/components/form/SearchEngineForm.test.tsx b/test/settings/components/form/SearchEngineForm.test.tsx index c9a68b4..8b84e12 100644 --- a/test/settings/components/form/SearchEngineForm.test.tsx +++ b/test/settings/components/form/SearchEngineForm.test.tsx @@ -8,7 +8,6 @@ import ReactTestRenderer from "react-test-renderer"; import ReactTestUtils from "react-dom/test-utils"; import SearchForm from "../../../../src/settings/components/form/SearchForm"; import { FormSearch } from "../../../../src/shared/SettingData"; -import { expect } from "chai"; describe("settings/form/SearchForm", () => { describe("render", () => { @@ -28,16 +27,16 @@ describe("settings/form/SearchForm", () => { const names = root .findAllByType("input") .filter((instance) => instance.props.name === "name"); - expect(names).to.have.lengthOf(2); - expect(names[0].props.value).to.equal("google"); - expect(names[1].props.value).to.equal("yahoo"); + expect(names).toHaveLength(2); + expect(names[0].props.value).toEqual("google"); + expect(names[1].props.value).toEqual("yahoo"); const urls = root .findAllByType("input") .filter((instance) => instance.props.name === "url"); - expect(urls).to.have.lengthOf(2); - expect(urls[0].props.value).to.equal("google.com"); - expect(urls[1].props.value).to.equal("yahoo.com"); + expect(urls).toHaveLength(2); + expect(urls[0].props.value).toEqual("google.com"); + expect(urls[1].props.value).toEqual("yahoo.com"); }); }); @@ -66,9 +65,9 @@ describe("settings/form/SearchForm", () => { })} onChange={(value) => { const json = value.toJSON(); - expect(json.default).to.equal("louvre"); - expect(json.engines).to.have.lengthOf(2); - expect(json.engines).to.have.deep.members([ + expect(json.default).toEqual("louvre"); + expect(json.engines).toHaveLength(2); + expect(json.engines).toEqual([ ["louvre", "google.com"], ["yahoo", "yahoo.com"], ]); @@ -105,11 +104,9 @@ describe("settings/form/SearchForm", () => { })} onChange={(value) => { const json = value.toJSON(); - expect(json.default).to.equal("yahoo"); - expect(json.engines).to.have.lengthOf(1); - expect(json.engines).to.have.deep.members([ - ["yahoo", "yahoo.com"], - ]); + expect(json.default).toEqual("yahoo"); + expect(json.engines).toHaveLength(1); + expect(json.engines).toEqual([["yahoo", "yahoo.com"]]); done(); }} />, @@ -133,9 +130,9 @@ describe("settings/form/SearchForm", () => { })} onChange={(value) => { const json = value.toJSON(); - expect(json.default).to.equal("yahoo"); - expect(json.engines).to.have.lengthOf(2); - expect(json.engines).to.have.deep.members([ + expect(json.default).toEqual("yahoo"); + expect(json.engines).toHaveLength(2); + expect(json.engines).toEqual([ ["google", "google.com"], ["", ""], ]); diff --git a/test/settings/components/ui/Radio.test.tsx b/test/settings/components/ui/Radio.test.tsx index bce4d3a..e2bf214 100644 --- a/test/settings/components/ui/Radio.test.tsx +++ b/test/settings/components/ui/Radio.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import ReactDOM from "react-dom"; import ReactTestUtils from "react-dom/test-utils"; import Radio from "../../../../src/settings/components/ui/Radio"; -import { expect } from "chai"; describe("settings/ui/Radio", () => { let container: HTMLDivElement; @@ -30,10 +29,10 @@ describe("settings/ui/Radio", () => { const label = document.querySelector("label")!; const input = document.querySelector("input")!; - expect(label.textContent).to.contain("myfield"); - expect(input.type).to.contain("radio"); - expect(input.name).to.contain("myradio"); - expect(input.value).to.contain("myvalue"); + expect(label.textContent).toEqual("myfield"); + expect(input.type).toEqual("radio"); + expect(input.name).toEqual("myradio"); + expect(input.value).toEqual("myvalue"); }); it("invoke onChange", (done) => { @@ -45,7 +44,7 @@ describe("settings/ui/Radio", () => { label="myfield" value="myvalue" onChange={(e) => { - expect((e.target as HTMLInputElement).checked).to.be.true; + expect((e.target as HTMLInputElement).checked).toBeTruthy; done(); }} />, diff --git a/test/settings/components/ui/Text.test.tsx b/test/settings/components/ui/Text.test.tsx index 86c4132..a8e0bf9 100644 --- a/test/settings/components/ui/Text.test.tsx +++ b/test/settings/components/ui/Text.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import ReactDOM from "react-dom"; import ReactTestUtils from "react-dom/test-utils"; import Text from "../../../../src/settings/components/ui/Text"; -import { expect } from "chai"; describe("settings/ui/Text", () => { let container: HTMLDivElement; @@ -30,10 +29,10 @@ describe("settings/ui/Text", () => { const label = document.querySelector("label")!; const input = document.querySelector("input")!; - expect(label.textContent).to.contain("myfield"); - expect(input.type).to.contain("text"); - expect(input.name).to.contain("myname"); - expect(input.value).to.contain("myvalue"); + expect(label.textContent?.includes("myfield")).toBeTruthy; + expect(input.type).toEqual("text"); + expect(input.name).toEqual("myname"); + expect(input.value).toEqual("myvalue"); }); it("invoke onChange", (done) => { @@ -44,7 +43,7 @@ describe("settings/ui/Text", () => { label="myfield" value="myvalue" onChange={(e) => { - expect((e.target as HTMLInputElement).value).to.equal("newvalue"); + expect((e.target as HTMLInputElement).value).toEqual("newvalue"); done(); }} />, diff --git a/test/settings/components/ui/TextArea.test.tsx b/test/settings/components/ui/TextArea.test.tsx index 84c0c93..76caec2 100644 --- a/test/settings/components/ui/TextArea.test.tsx +++ b/test/settings/components/ui/TextArea.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import ReactDOM from "react-dom"; import ReactTestUtils from "react-dom/test-utils"; import TextArea from "../../../../src/settings/components/ui/TextArea"; -import { expect } from "chai"; describe("settings/ui/TextArea", () => { let container: HTMLDivElement; @@ -36,11 +35,11 @@ describe("settings/ui/TextArea", () => { const label = document.querySelector("label")!; const textarea = document.querySelector("textarea")!; const error = document.querySelector("[role=alert]")!; - expect(label.textContent).to.contain("myfield"); - expect(textarea.nodeName).to.contain("TEXTAREA"); - expect(textarea.name).to.contain("myname"); - expect(textarea.value).to.contain("myvalue"); - expect(error.textContent).to.contain("myerror"); + expect(label.textContent).toEqual("myfield"); + expect(textarea.nodeName).toEqual("TEXTAREA"); + expect(textarea.name).toEqual("myname"); + expect(textarea.value).toEqual("myvalue"); + expect(error.textContent).toEqual("myerror"); }); it("invoke onChange", (done) => { @@ -51,9 +50,7 @@ describe("settings/ui/TextArea", () => { label="myfield" value="myvalue" onChange={(e) => { - expect((e.target as HTMLTextAreaElement).value).to.equal( - "newvalue" - ); + expect((e.target as HTMLTextAreaElement).value).toEqual("newvalue"); done(); }} />, diff --git a/test/settings/reducers/setting.test.ts b/test/settings/reducers/setting.test.ts index 34e76e2..85b55ee 100644 --- a/test/settings/reducers/setting.test.ts +++ b/test/settings/reducers/setting.test.ts @@ -1,6 +1,5 @@ import * as actions from "../../../src/settings/actions"; import settingReducer from "../../../src/settings/reducers/setting"; -import { expect } from "chai"; import { FormSettings, JSONTextSettings, @@ -11,8 +10,8 @@ import { DefaultSetting } from "../../../src/shared/settings/Settings"; describe("settings setting reducer", () => { it("return the initial state", () => { const state = settingReducer(undefined, {} as any); - expect(state).to.have.deep.property("source", "json"); - expect(state).to.have.deep.property("error", ""); + expect(state).toHaveProperty("source", "json"); + expect(state).toHaveProperty("error", ""); }); it("return next state for SETTING_SET_SETTINGS", () => { @@ -23,9 +22,9 @@ describe("settings setting reducer", () => { form: FormSettings.fromSettings(DefaultSetting), }; const state = settingReducer(undefined, action); - expect(state.source).to.equal("json"); - expect(state.json!.toJSONText()).to.equal('{ "key": "value" }'); - expect(state.form).to.deep.equal(action.form); + expect(state.source).toEqual("json"); + expect(state.json!.toJSONText()).toEqual('{ "key": "value" }'); + expect(state.form).toEqual(action.form); }); it("return next state for SETTING_SHOW_ERROR", () => { @@ -35,8 +34,8 @@ describe("settings setting reducer", () => { json: JSONTextSettings.fromText("{}"), }; const state = settingReducer(undefined, action); - expect(state.error).to.equal("bad value"); - expect(state.json!.toJSONText()).to.equal("{}"); + expect(state.error).toEqual("bad value"); + expect(state.json!.toJSONText()).toEqual("{}"); }); it("return next state for SETTING_SWITCH_TO_FORM", () => { @@ -45,8 +44,8 @@ describe("settings setting reducer", () => { form: FormSettings.fromSettings(DefaultSetting), }; const state = settingReducer(undefined, action); - expect(state.form).to.deep.equal(action.form); - expect(state.source).to.equal("form"); + expect(state.form).toEqual(action.form); + expect(state.source).toEqual("form"); }); it("return next state for SETTING_SWITCH_TO_JSON", () => { @@ -55,7 +54,7 @@ describe("settings setting reducer", () => { json: JSONTextSettings.fromText("{}"), }; const state = settingReducer(undefined, action); - expect(state.json!.toJSONText()).to.equal("{}"); - expect(state.source).to.equal(SettingSource.JSON); + expect(state.json!.toJSONText()).toEqual("{}"); + expect(state.source).toEqual(SettingSource.JSON); }); }); diff --git a/test/shared/SettingData.test.ts b/test/shared/SettingData.test.ts index 3cfd5c9..f2c4aa9 100644 --- a/test/shared/SettingData.test.ts +++ b/test/shared/SettingData.test.ts @@ -4,7 +4,6 @@ import SettingData, { FormSettings, } from "../../src/shared/SettingData"; import Settings from "../../src/shared/settings/Settings"; -import { expect } from "chai"; import Keymaps from "../../src/shared/settings/Keymaps"; import ColorScheme from "../../src/shared/ColorScheme"; @@ -18,7 +17,7 @@ describe("shared/SettingData", () => { }; const keymaps = FormKeymaps.fromJSON(data).toKeymaps().toJSON(); - expect(keymaps).to.deep.equal({ + expect(keymaps).toEqual({ j: { type: "scroll.vertically", count: 1 }, "0": { type: "scroll.home" }, }); @@ -33,7 +32,7 @@ describe("shared/SettingData", () => { }); const form = FormKeymaps.fromKeymaps(keymaps).toJSON(); - expect(form).to.deep.equal({ + expect(form).toEqual({ 'scroll.vertically?{"count":1}': "j", "scroll.home": "0", }); @@ -62,7 +61,7 @@ describe("shared/SettingData", () => { }`; const settings = JSONTextSettings.fromText(o).toSettings(); - expect(settings.toJSON()).to.deep.equal(JSON.parse(o)); + expect(settings.toJSON()).toEqual(JSON.parse(o)); }); }); @@ -85,7 +84,7 @@ describe("shared/SettingData", () => { }); const json = JSONTextSettings.fromSettings(o).toJSONText(); - expect(JSON.parse(json)).to.deep.equal(o.toJSON()); + expect(JSON.parse(json)).toEqual(o.toJSON()); }); }); }); @@ -112,7 +111,7 @@ describe("shared/SettingData", () => { }; const settings = FormSettings.fromJSON(data).toSettings(); - expect(settings.toJSON()).to.deep.equal({ + expect(settings.toJSON()).toEqual({ keymaps: { j: { type: "scroll.vertically", count: 1 }, "0": { type: "scroll.home" }, @@ -157,7 +156,7 @@ describe("shared/SettingData", () => { }); const json = FormSettings.fromSettings(data).toJSON(); - expect(json).to.deep.equal({ + expect(json).toEqual({ keymaps: { 'scroll.vertically?{"count":1}': "j", "scroll.home": "0", @@ -202,8 +201,8 @@ describe("shared/SettingData", () => { }; const j = SettingData.fromJSON(data).toJSON(); - expect(j.source).to.equal("json"); - expect(j.json).to.be.a("string"); + expect(j.source).toEqual("json"); + expect(typeof j.json).toEqual("string"); }); it("parse object from form source", () => { @@ -226,8 +225,8 @@ describe("shared/SettingData", () => { }; const j = SettingData.fromJSON(data).toJSON(); - expect(j.source).to.equal("form"); - expect(j.form).to.deep.equal({ + expect(j.source).toEqual("form"); + expect(j.form).toEqual({ keymaps: {}, search: { default: "yahoo", @@ -266,7 +265,7 @@ describe("shared/SettingData", () => { }; const settings = SettingData.fromJSON(data).toSettings(); - expect(settings.search.defaultEngine).to.equal("google"); + expect(settings.search.defaultEngine).toEqual("google"); }); it("parse object from form source", () => { @@ -288,7 +287,7 @@ describe("shared/SettingData", () => { }; const settings = SettingData.fromJSON(data).toSettings(); - expect(settings.search.defaultEngine).to.equal("yahoo"); + expect(settings.search.defaultEngine).toEqual("yahoo"); }); }); }); diff --git a/test/shared/operations.test.ts b/test/shared/operations.test.ts index 449b25e..9fa9e19 100644 --- a/test/shared/operations.test.ts +++ b/test/shared/operations.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../src/shared/operations"; -import { expect } from "chai"; describe("operations", () => { describe("#valueOf", () => { @@ -8,8 +7,8 @@ describe("operations", () => { type: operations.SCROLL_VERTICALLY, count: 10, }) as operations.ScrollVerticallyOperation; - expect(op.type).to.equal(operations.SCROLL_VERTICALLY); - expect(op.count).to.equal(10); + expect(op.type).toEqual(operations.SCROLL_VERTICALLY); + expect(op.count).toEqual(10); }); it("throws an Error on missing required parameter", () => { @@ -17,7 +16,7 @@ describe("operations", () => { operations.valueOf({ type: operations.SCROLL_VERTICALLY, }) - ).to.throw(TypeError); + ).toThrow(TypeError); }); it("fills default valus of optional parameter", () => { @@ -25,8 +24,8 @@ describe("operations", () => { type: operations.COMMAND_SHOW_OPEN, }) as operations.CommandShowOpenOperation; - expect(op.type).to.equal(operations.COMMAND_SHOW_OPEN); - expect(op.alter).to.be.false; + expect(op.type).toEqual(operations.COMMAND_SHOW_OPEN); + expect(op.alter).toBeFalsy; }); it("throws an Error on mismatch of parameter", () => { @@ -35,14 +34,14 @@ describe("operations", () => { type: operations.SCROLL_VERTICALLY, count: "10", }) - ).to.throw(TypeError); + ).toThrow(TypeError); expect(() => operations.valueOf({ type: operations.COMMAND_SHOW_OPEN, alter: "true", }) - ).to.throw(TypeError); + ).toThrow(TypeError); }); }); }); diff --git a/test/shared/settings/Blacklist.test.ts b/test/shared/settings/Blacklist.test.ts index 1ccb32a..af7b946 100644 --- a/test/shared/settings/Blacklist.test.ts +++ b/test/shared/settings/Blacklist.test.ts @@ -1,15 +1,14 @@ import Blacklist, { BlacklistItem, } from "../../../src/shared/settings/Blacklist"; -import { expect } from "chai"; import Key from "../../../src/shared/settings/Key"; describe("BlacklistItem", () => { describe("#fromJSON", () => { it("parses string pattern", () => { const item = BlacklistItem.fromJSON("example.com"); - expect(item.pattern).to.equal("example.com"); - expect(item.partial).to.be.false; + expect(item.pattern).toEqual("example.com"); + expect(item.partial).toBeFalsy; }); it("parses partial blacklist item", () => { @@ -17,56 +16,56 @@ describe("BlacklistItem", () => { url: "example.com", keys: ["j", "k"], }); - expect(item.pattern).to.equal("example.com"); - expect(item.partial).to.be.true; - expect(item.keys).to.deep.equal(["j", "k"]); + expect(item.pattern).toEqual("example.com"); + expect(item.partial).toBeTruthy; + expect(item.keys).toEqual(["j", "k"]); }); }); describe("#matches", () => { it('matches by "*"', () => { const item = BlacklistItem.fromJSON("*"); - expect(item.matches(new URL("https://github.com/abc"))).to.be.true; + expect(item.matches(new URL("https://github.com/abc"))).toBeTruthy; }); it("matches by hostname", () => { const item = BlacklistItem.fromJSON("github.com"); - expect(item.matches(new URL("https://github.com"))).to.be.true; - expect(item.matches(new URL("https://gist.github.com"))).to.be.false; - expect(item.matches(new URL("https://github.com/ueokande"))).to.be.true; - expect(item.matches(new URL("https://github.org"))).to.be.false; - expect(item.matches(new URL("https://google.com/search?q=github.org"))).to - .be.false; + expect(item.matches(new URL("https://github.com"))).toBeTruthy; + expect(item.matches(new URL("https://gist.github.com"))).toBeFalsy; + expect(item.matches(new URL("https://github.com/ueokande"))).toBeTruthy; + expect(item.matches(new URL("https://github.org"))).toBeFalsy; + expect(item.matches(new URL("https://google.com/search?q=github.org"))) + .toBeFalsy; }); it("matches by hostname with wildcard", () => { const item = BlacklistItem.fromJSON("*.github.com"); - expect(item.matches(new URL("https://github.com"))).to.be.false; - expect(item.matches(new URL("https://gist.github.com"))).to.be.true; + expect(item.matches(new URL("https://github.com"))).toBeFalsy; + expect(item.matches(new URL("https://gist.github.com"))).toBeTruthy; }); it("matches by path", () => { const item = BlacklistItem.fromJSON("github.com/abc"); - expect(item.matches(new URL("https://github.com/abc"))).to.be.true; - expect(item.matches(new URL("https://github.com/abcdef"))).to.be.false; - expect(item.matches(new URL("https://gist.github.com/abc"))).to.be.false; + expect(item.matches(new URL("https://github.com/abc"))).toBeTruthy; + expect(item.matches(new URL("https://github.com/abcdef"))).toBeFalsy; + expect(item.matches(new URL("https://gist.github.com/abc"))).toBeFalsy; }); it("matches by path with wildcard", () => { const item = BlacklistItem.fromJSON("github.com/abc*"); - expect(item.matches(new URL("https://github.com/abc"))).to.be.true; - expect(item.matches(new URL("https://github.com/abcdef"))).to.be.true; - expect(item.matches(new URL("https://gist.github.com/abc"))).to.be.false; + expect(item.matches(new URL("https://github.com/abc"))).toBeTruthy; + expect(item.matches(new URL("https://github.com/abcdef"))).toBeTruthy; + expect(item.matches(new URL("https://gist.github.com/abc"))).toBeFalsy; }); it("matches address and port", () => { const item = BlacklistItem.fromJSON("127.0.0.1:8888"); - expect(item.matches(new URL("http://127.0.0.1:8888/"))).to.be.true; - expect(item.matches(new URL("http://127.0.0.1:8888/hello"))).to.be.true; + expect(item.matches(new URL("http://127.0.0.1:8888/"))).toBeTruthy; + expect(item.matches(new URL("http://127.0.0.1:8888/hello"))).toBeTruthy; }); it("matches with partial blacklist", () => { @@ -75,8 +74,8 @@ describe("BlacklistItem", () => { keys: ["j", "k"], }); - expect(item.matches(new URL("https://google.com"))).to.be.true; - expect(item.matches(new URL("https://yahoo.com"))).to.be.false; + expect(item.matches(new URL("https://google.com"))).toBeTruthy; + expect(item.matches(new URL("https://yahoo.com"))).toBeFalsy; }); }); @@ -89,22 +88,22 @@ describe("BlacklistItem", () => { expect( item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("j")) - ).to.be.true; + ).toBeTruthy; expect( item.includeKey( new URL("http://google.com/maps"), Key.fromMapKey("<C-U>") ) - ).to.be.true; + ).toBeTruthy; expect( item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("z")) - ).to.be.false; + ).toBeFalsy; expect( item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("u")) - ).to.be.false; + ).toBeFalsy; expect( item.includeKey(new URL("http://maps.google.com/"), Key.fromMapKey("j")) - ).to.be.false; + ).toBeFalsy; }); }); }); @@ -113,7 +112,7 @@ describe("Blacklist", () => { describe("#fromJSON", () => { it("parses string list", () => { const blacklist = Blacklist.fromJSON(["example.com", "example.org"]); - expect(blacklist.toJSON()).to.deep.equals(["example.com", "example.org"]); + expect(blacklist.toJSON()).toEqual(["example.com", "example.org"]); }); it("parses mixed blacklist", () => { @@ -121,7 +120,7 @@ describe("Blacklist", () => { { url: "example.com", keys: ["j", "k"] }, "example.org", ]); - expect(blacklist.toJSON()).to.deep.equals([ + expect(blacklist.toJSON()).toEqual([ { url: "example.com", keys: ["j", "k"] }, "example.org", ]); @@ -129,7 +128,7 @@ describe("Blacklist", () => { it("parses empty blacklist", () => { const blacklist = Blacklist.fromJSON([]); - expect(blacklist.toJSON()).to.deep.equals([]); + expect(blacklist.toJSON()).toEqual([]); }); }); @@ -137,12 +136,12 @@ describe("Blacklist", () => { it("matches a url with entire blacklist", () => { const blacklist = Blacklist.fromJSON(["google.com", "*.github.com"]); expect(blacklist.includesEntireBlacklist(new URL("https://google.com"))) - .to.be.true; + .toBeTruthy; expect(blacklist.includesEntireBlacklist(new URL("https://github.com"))) - .to.be.false; + .toBeFalsy; expect( blacklist.includesEntireBlacklist(new URL("https://gist.github.com")) - ).to.be.true; + ).toBeTruthy; }); it("does not matches with partial blacklist", () => { @@ -151,9 +150,9 @@ describe("Blacklist", () => { { url: "yahoo.com", keys: ["j", "k"] }, ]); expect(blacklist.includesEntireBlacklist(new URL("https://google.com"))) - .to.be.true; - expect(blacklist.includesEntireBlacklist(new URL("https://yahoo.com"))).to - .be.false; + .toBeTruthy; + expect(blacklist.includesEntireBlacklist(new URL("https://yahoo.com"))) + .toBeFalsy; }); }); @@ -166,13 +165,13 @@ describe("Blacklist", () => { expect( blacklist.includeKey(new URL("https://google.com"), Key.fromMapKey("j")) - ).to.be.false; + ).toBeFalsy; expect( blacklist.includeKey(new URL("https://github.com"), Key.fromMapKey("j")) - ).to.be.true; + ).toBeTruthy; expect( blacklist.includeKey(new URL("https://github.com"), Key.fromMapKey("a")) - ).to.be.false; + ).toBeFalsy; }); }); }); diff --git a/test/shared/settings/Key.test.ts b/test/shared/settings/Key.test.ts index 47af1d9..8ad9265 100644 --- a/test/shared/settings/Key.test.ts +++ b/test/shared/settings/Key.test.ts @@ -1,89 +1,88 @@ -import { expect } from "chai"; import Key from "../../../src/shared/settings/Key"; describe("Key", () => { describe("fromMapKey", () => { it("return for X", () => { const key = Key.fromMapKey("x"); - expect(key.key).to.equal("x"); - expect(key.shift).to.be.false; - expect(key.ctrl).to.be.false; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("x"); + expect(key.shift).toBeFalsy; + expect(key.ctrl).toBeFalsy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; }); it("return for Shift+X", () => { const key = Key.fromMapKey("X"); - expect(key.key).to.equal("X"); - expect(key.shift).to.be.true; - expect(key.ctrl).to.be.false; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("X"); + expect(key.shift).toBeTruthy; + expect(key.ctrl).toBeFalsy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; }); it("return for Ctrl+X", () => { const key = Key.fromMapKey("<C-X>"); - expect(key.key).to.equal("x"); - expect(key.shift).to.be.false; - expect(key.ctrl).to.be.true; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("x"); + expect(key.shift).toBeFalsy; + expect(key.ctrl).toBeTruthy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; }); it("returns for Ctrl+Meta+X", () => { const key = Key.fromMapKey("<C-M-X>"); - expect(key.key).to.equal("x"); - expect(key.shift).to.be.false; - expect(key.ctrl).to.be.true; - expect(key.alt).to.be.false; - expect(key.meta).to.be.true; + expect(key.key).toEqual("x"); + expect(key.shift).toBeFalsy; + expect(key.ctrl).toBeTruthy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeTruthy; }); it("returns for Ctrl+Shift+x", () => { const key = Key.fromMapKey("<C-S-x>"); - expect(key.key).to.equal("X"); - expect(key.shift).to.be.true; - expect(key.ctrl).to.be.true; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("X"); + expect(key.shift).toBeTruthy; + expect(key.ctrl).toBeTruthy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; }); it("returns for Shift+Esc", () => { const key = Key.fromMapKey("<S-Esc>"); - expect(key.key).to.equal("Esc"); - expect(key.shift).to.be.true; - expect(key.ctrl).to.be.false; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("Esc"); + expect(key.shift).toBeTruthy; + expect(key.ctrl).toBeFalsy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; }); it("returns for Ctrl+Esc", () => { const key = Key.fromMapKey("<C-Esc>"); - expect(key.key).to.equal("Esc"); - expect(key.shift).to.be.false; - expect(key.ctrl).to.be.true; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("Esc"); + expect(key.shift).toBeFalsy; + expect(key.ctrl).toBeTruthy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; }); it("returns for Ctrl+Esc", () => { const key = Key.fromMapKey("<C-Space>"); - expect(key.key).to.equal("Space"); - expect(key.shift).to.be.false; - expect(key.ctrl).to.be.true; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("Space"); + expect(key.shift).toBeFalsy; + expect(key.ctrl).toBeTruthy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; }); }); describe("idDigit", () => { it("returns true if the key is a digit", () => { - expect(new Key({ key: "0" }).isDigit()).to.be.true; - expect(new Key({ key: "9" }).isDigit()).to.be.true; - expect(new Key({ key: "9", alt: true }).isDigit()).to.be.false; + expect(new Key({ key: "0" }).isDigit()).toBeTruthy; + expect(new Key({ key: "9" }).isDigit()).toBeTruthy; + expect(new Key({ key: "9", alt: true }).isDigit()).toBeFalsy; - expect(new Key({ key: "a" }).isDigit()).to.be.false; - expect(new Key({ key: "0" }).isDigit()).to.be.false; + expect(new Key({ key: "a" }).isDigit()).toBeFalsy; + expect(new Key({ key: "0" }).isDigit()).toBeFalsy; }); }); @@ -105,7 +104,7 @@ describe("Key", () => { meta: false, }) ) - ).to.be.true; + ).toBeTruthy; expect( new Key({ @@ -123,7 +122,7 @@ describe("Key", () => { meta: false, }) ) - ).to.be.false; + ).toBeFalsy; }); }); }); diff --git a/test/shared/settings/Keymaps.test.ts b/test/shared/settings/Keymaps.test.ts index 264684d..850e327 100644 --- a/test/shared/settings/Keymaps.test.ts +++ b/test/shared/settings/Keymaps.test.ts @@ -1,11 +1,10 @@ import Keymaps from "../../../src/shared/settings/Keymaps"; -import { expect } from "chai"; describe("Keymaps", () => { describe("#valueOf", () => { it("returns empty object by empty settings", () => { const keymaps = Keymaps.fromJSON({}).toJSON(); - expect(keymaps).to.be.empty; + expect(keymaps).toEqual({}); }); it("returns keymaps by valid settings", () => { @@ -14,11 +13,11 @@ describe("Keymaps", () => { j: { type: "scroll.vertically", count: 1 }, }).toJSON(); - expect(keymaps["k"]).to.deep.equal({ + expect(keymaps["k"]).toEqual({ type: "scroll.vertically", count: -1, }); - expect(keymaps["j"]).to.deep.equal({ + expect(keymaps["j"]).toEqual({ type: "scroll.vertically", count: 1, }); @@ -29,7 +28,7 @@ describe("Keymaps", () => { Keymaps.fromJSON({ k: { type: "invalid.operation" }, }) - ).to.throw(TypeError); + ).toThrow(TypeError); }); }); @@ -48,7 +47,7 @@ describe("Keymaps", () => { const entries = keymaps .entries() .sort(([name1], [name2]) => name1.localeCompare(name2)); - expect(entries).deep.equals([ + expect(entries).toEqual([ ["j", { type: "scroll.vertically", count: 1 }], ["k", { type: "scroll.vertically", count: -1 }], ["n", { type: "find.next" }], @@ -70,7 +69,7 @@ describe("Keymaps", () => { const entries = keymaps .entries() .sort(([name1], [name2]) => name1.localeCompare(name2)); - expect(entries).deep.equals([ + expect(entries).toEqual([ ["j", { type: "find.prev" }], ["k", { type: "scroll.vertically", count: -1 }], ["n", { type: "find.next" }], diff --git a/test/shared/settings/Properties.test.ts b/test/shared/settings/Properties.test.ts index 647cb1c..1161b48 100644 --- a/test/shared/settings/Properties.test.ts +++ b/test/shared/settings/Properties.test.ts @@ -1,12 +1,11 @@ import Properties from "../../../src/shared/settings/Properties"; -import { expect } from "chai"; import ColorScheme from "../../../src/shared/ColorScheme"; describe("Properties", () => { describe("#propertiesValueOf", () => { it("returns with default properties by empty settings", () => { const props = Properties.fromJSON({}); - expect(props).to.deep.equal({ + expect(props).toEqual({ hintchars: "abcdefghijklmnopqrstuvwxyz", smoothscroll: false, complete: "sbh", @@ -22,7 +21,7 @@ describe("Properties", () => { colorscheme: ColorScheme.System, }); - expect(props).to.deep.equal({ + expect(props).toEqual({ hintchars: "abcdefgh", smoothscroll: false, complete: "sbh", diff --git a/test/shared/settings/Search.test.ts b/test/shared/settings/Search.test.ts index 1feb14b..5d2f8d5 100644 --- a/test/shared/settings/Search.test.ts +++ b/test/shared/settings/Search.test.ts @@ -1,5 +1,4 @@ import Search from "../../../src/shared/settings/Search"; -import { expect } from "chai"; describe("Search", () => { it("returns search settings by valid settings", () => { @@ -11,12 +10,12 @@ describe("Search", () => { }, }); - expect(search.defaultEngine).to.equal("google"); - expect(search.engines).to.deep.equals({ + expect(search.defaultEngine).toEqual("google"); + expect(search.engines).toEqual({ google: "https://google.com/search?q={}", yahoo: "https://search.yahoo.com/search?p={}", }); - expect(search.toJSON()).to.deep.equal({ + expect(search.toJSON()).toEqual({ default: "google", engines: { google: "https://google.com/search?q={}", @@ -34,7 +33,7 @@ describe("Search", () => { yahoo: "https://search.yahoo.com/search?p={}", }, }) - ).to.throw(TypeError); + ).toThrow(TypeError); expect(() => Search.fromJSON({ default: "g o o g l e", @@ -42,7 +41,7 @@ describe("Search", () => { "g o o g l e": "https://google.com/search?q={}", }, }) - ).to.throw(TypeError); + ).toThrow(TypeError); expect(() => Search.fromJSON({ default: "google", @@ -50,7 +49,7 @@ describe("Search", () => { google: "https://google.com/search", }, }) - ).to.throw(TypeError); + ).toThrow(TypeError); expect(() => Search.fromJSON({ default: "google", @@ -58,6 +57,6 @@ describe("Search", () => { google: "https://google.com/search?q={}&r={}", }, }) - ).to.throw(TypeError); + ).toThrow(TypeError); }); }); diff --git a/test/shared/settings/Settings.test.ts b/test/shared/settings/Settings.test.ts index 951c9cd..49a5d0b 100644 --- a/test/shared/settings/Settings.test.ts +++ b/test/shared/settings/Settings.test.ts @@ -1,5 +1,4 @@ import Settings from "../../../src/shared/settings/Settings"; -import { expect } from "chai"; describe("Settings", () => { describe("#valueOf", () => { @@ -21,7 +20,7 @@ describe("Settings", () => { search: x.search.toJSON(), properties: x.properties.toJSON(), blacklist: x.blacklist.toJSON(), - }).to.deep.equal({ + }).toEqual({ keymaps: {}, search: { default: "google", @@ -41,15 +40,15 @@ describe("Settings", () => { it("sets default settings", () => { const value = Settings.fromJSON({}); - expect(value.keymaps.toJSON()).to.not.be.empty; - expect(value.properties.toJSON()).to.not.be.empty; - expect(value.search.defaultEngine).to.be.a("string"); - expect(value.search.engines).to.be.an("object"); - expect(value.blacklist.toJSON()).to.be.empty; + expect(value.keymaps.toJSON()).not.toEqual({}); + expect(value.properties.toJSON()).not.toEqual({}); + expect(typeof value.search.defaultEngine).toEqual("string"); + expect(typeof value.search.engines).toEqual("object"); + expect(value.blacklist.toJSON()).toHaveLength(0); }); it("throws a TypeError with an unknown field", () => { - expect(() => Settings.fromJSON({ name: "alice" })).to.throw(TypeError); + expect(() => Settings.fromJSON({ name: "alice" })).toThrow(TypeError); }); }); }); diff --git a/test/shared/urls.test.ts b/test/shared/urls.test.ts index f264ad9..ec618f6 100644 --- a/test/shared/urls.test.ts +++ b/test/shared/urls.test.ts @@ -1,5 +1,4 @@ import * as parsers from "../../src/shared/urls"; -import { expect } from "chai"; import Search from "../../src/shared/settings/Search"; describe("shared/commands/parsers", () => { @@ -13,55 +12,55 @@ describe("shared/commands/parsers", () => { }); it("convertes search url", () => { - expect(parsers.searchUrl("google.com", config)).to.equal( + expect(parsers.searchUrl("google.com", config)).toEqual( "http://google.com" ); - expect(parsers.searchUrl("google apple", config)).to.equal( + expect(parsers.searchUrl("google apple", config)).toEqual( "https://google.com/search?q=apple" ); - expect(parsers.searchUrl("yahoo apple", config)).to.equal( + expect(parsers.searchUrl("yahoo apple", config)).toEqual( "https://yahoo.com/search?q=apple" ); - expect(parsers.searchUrl("google apple banana", config)).to.equal( + expect(parsers.searchUrl("google apple banana", config)).toEqual( "https://google.com/search?q=apple%20banana" ); - expect(parsers.searchUrl("yahoo C++CLI", config)).to.equal( + expect(parsers.searchUrl("yahoo C++CLI", config)).toEqual( "https://yahoo.com/search?q=C%2B%2BCLI" ); }); it("user default search engine", () => { - expect(parsers.searchUrl("apple banana", config)).to.equal( + expect(parsers.searchUrl("apple banana", config)).toEqual( "https://google.com/search?q=apple%20banana" ); }); it("searches with a word containing a colon", () => { - expect(parsers.searchUrl("foo:", config)).to.equal( + expect(parsers.searchUrl("foo:", config)).toEqual( "https://google.com/search?q=foo%3A" ); - expect(parsers.searchUrl("std::vector", config)).to.equal( + expect(parsers.searchUrl("std::vector", config)).toEqual( "https://google.com/search?q=std%3A%3Avector" ); }); it("localhost urls", () => { - expect(parsers.searchUrl("localhost", config)).to.equal( + expect(parsers.searchUrl("localhost", config)).toEqual( "http://localhost" ); - expect(parsers.searchUrl("http://localhost", config)).to.equal( + expect(parsers.searchUrl("http://localhost", config)).toEqual( "http://localhost/" ); - expect(parsers.searchUrl("localhost:8080", config)).to.equal( + expect(parsers.searchUrl("localhost:8080", config)).toEqual( "http://localhost:8080" ); - expect(parsers.searchUrl("localhost:80nan", config)).to.equal( + expect(parsers.searchUrl("localhost:80nan", config)).toEqual( "https://google.com/search?q=localhost%3A80nan" ); - expect(parsers.searchUrl("localhost 8080", config)).to.equal( + expect(parsers.searchUrl("localhost 8080", config)).toEqual( "https://google.com/search?q=localhost%208080" ); - expect(parsers.searchUrl("localhost:80/build", config)).to.equal( + expect(parsers.searchUrl("localhost:80/build", config)).toEqual( "http://localhost:80/build" ); }); @@ -69,10 +68,10 @@ describe("shared/commands/parsers", () => { describe("#normalizeUrl", () => { it("normalize urls", () => { - expect(parsers.normalizeUrl("https://google.com/")).to.equal( + expect(parsers.normalizeUrl("https://google.com/")).toEqual( "https://google.com/" ); - expect(parsers.normalizeUrl("google.com")).to.equal("http://google.com"); + expect(parsers.normalizeUrl("google.com")).toEqual("http://google.com"); }); }); }); |