From e304581fb15eabb3a973d363a282ee7546561e01 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 26 Sep 2021 17:01:31 +0900 Subject: Do not use chai on unit test --- test/content/InputDriver.test.ts | 67 ++++++++-------- test/content/domains/KeySequence.test.ts | 77 +++++++++---------- .../impls/AddonOperatorFactoryChain.test.ts | 13 ++-- .../impls/BackgroundOperationOperator.test.ts | 3 +- .../impls/ClipboardOperatorFactoryChain.test.ts | 7 +- .../operators/impls/DisableAddonOperator.test.ts | 7 +- .../operators/impls/EnableAddonOperator.test.ts | 7 +- .../operators/impls/EnableJumpMarkOperator.test.ts | 3 +- .../operators/impls/EnableSetMarkOperator.test.ts | 3 +- .../impls/FocusOperatorFactoryChain.test.ts | 5 +- .../impls/FollowOperatorFactoryChain.test.ts | 5 +- .../impls/HorizontalScrollOperator.test.ts | 5 +- .../impls/MarkOperatorFactoryChain.test.ts | 7 +- .../operators/impls/PageScrollOperator.test.ts | 5 +- .../impls/ScrollOperatorFactoryChain.test.ts | 23 +++--- .../operators/impls/ScrollToBottomOperator.test.ts | 3 +- .../operators/impls/ScrollToEndOperator.test.ts | 3 +- .../operators/impls/ScrollToHomeOperator.test.ts | 3 +- .../operators/impls/ScrollToTopOperator.test.ts | 3 +- .../operators/impls/ToggleAddonOperator.test.ts | 13 ++-- .../operators/impls/VerticalScrollOperator.test.ts | 5 +- .../operators/impls/YankURLOperator.test.ts | 7 +- test/content/presenters/Hint.test.ts | 23 +++--- .../content/presenters/NavigationPresenter.test.ts | 3 +- .../repositories/AddonEnabledRepository.test.ts | 5 +- .../repositories/FollowKeyRepository.test.ts | 9 +-- .../repositories/FollowMasterRepository.test.ts | 23 +++--- .../repositories/FollowSlaveRepository.test.ts | 7 +- test/content/repositories/KeymapRepository.test.ts | 9 +-- .../content/repositories/MarkKeyRepository.test.ts | 13 ++-- test/content/repositories/MarkRepository.test.ts | 5 +- .../content/repositories/SettingRepository.test.ts | 3 +- test/content/usecases/AddonEnabledUseCase.test.ts | 29 ++++--- test/content/usecases/HintKeyProducer.test.ts | 13 ++-- test/content/usecases/KeymapUseCase.test.ts | 89 +++++++++++----------- test/content/usecases/MarkUseCase.test.ts | 15 ++-- test/content/usecases/SettingUseCaase.test.ts | 5 +- 37 files changed, 242 insertions(+), 283 deletions(-) (limited to 'test/content') diff --git a/test/content/InputDriver.test.ts b/test/content/InputDriver.test.ts index b0dde77..9ab0965 100644 --- a/test/content/InputDriver.test.ts +++ b/test/content/InputDriver.test.ts @@ -5,7 +5,6 @@ import InputDriver, { keyFromKeyboardEvent, } from "../../src/content/InputDriver"; -import { expect } from "chai"; import Key from "../../src/shared/settings/Key"; describe("InputDriver", () => { @@ -24,11 +23,11 @@ describe("InputDriver", () => { it("register callbacks", (done) => { driver.onKey((key: Key): boolean => { - expect(key.key).to.equal("a"); - expect(key.ctrl).to.be.true; - expect(key.shift).to.be.false; - expect(key.alt).to.be.false; - expect(key.meta).to.be.false; + expect(key.key).toEqual("a"); + expect(key.ctrl).toBeTruthy; + expect(key.shift).toBeFalsy; + expect(key.alt).toBeFalsy; + expect(key.meta).toBeFalsy; done(); return true; }); @@ -69,8 +68,8 @@ describe("InputDriver", () => { target.dispatchEvent(e); } - expect(a).to.equal(1); - expect(b).to.equal(1); + expect(a).toEqual(1); + expect(b).toEqual(1); }); it("propagates and stop handler chain", () => { @@ -92,14 +91,14 @@ describe("InputDriver", () => { target.dispatchEvent(new KeyboardEvent("keydown", { key: "b" })); - expect(a).to.equal(1); - expect(b).to.equal(1); - expect(c).to.equal(0); + expect(a).toEqual(1); + expect(b).toEqual(1); + expect(c).toEqual(0); }); it("does not invoke only meta keys", () => { driver.onKey((_key: Key): boolean => { - expect.fail(); + throw new Error("unexpected reach"); return false; }); @@ -114,7 +113,7 @@ describe("InputDriver", () => { const input = window.document.createElement(name); const driver = new InputDriver(input); driver.onKey((_key: Key): boolean => { - expect.fail(); + throw new Error("unexpected reach"); return false; }); input.dispatchEvent(new KeyboardEvent("keydown", { key: "x" })); @@ -125,7 +124,7 @@ describe("InputDriver", () => { const div = window.document.createElement("div"); const driver = new InputDriver(div); driver.onKey((_key: Key): boolean => { - expect.fail(); + throw new Error("unexpected reach"); return false; }); @@ -148,11 +147,11 @@ describe("#keyFromKeyboardEvent", () => { metaKey: true, }) ); - expect(k.key).to.equal("x"); - expect(k.shift).to.be.false; - expect(k.ctrl).to.be.true; - expect(k.alt).to.be.false; - expect(k.meta).to.be.true; + expect(k.key).toEqual("x"); + expect(k.shift).toBeFalsy; + expect(k.ctrl).toBeTruthy; + expect(k.alt).toBeFalsy; + expect(k.meta).toBeTruthy; }); it("returns from keyboard input Shift+Esc", () => { @@ -165,11 +164,11 @@ describe("#keyFromKeyboardEvent", () => { metaKey: true, }) ); - expect(k.key).to.equal("Esc"); - expect(k.shift).to.be.true; - expect(k.ctrl).to.be.false; - expect(k.alt).to.be.false; - expect(k.meta).to.be.true; + expect(k.key).toEqual("Esc"); + expect(k.shift).toBeTruthy; + expect(k.ctrl).toBeFalsy; + expect(k.alt).toBeFalsy; + expect(k.meta).toBeTruthy; }); it("returns from keyboard input Ctrl+$", () => { @@ -183,11 +182,11 @@ describe("#keyFromKeyboardEvent", () => { metaKey: false, }) ); - expect(k.key).to.equal("$"); - expect(k.shift).to.be.false; - expect(k.ctrl).to.be.true; - expect(k.alt).to.be.false; - expect(k.meta).to.be.false; + expect(k.key).toEqual("$"); + expect(k.shift).toBeFalsy; + expect(k.ctrl).toBeTruthy; + expect(k.alt).toBeFalsy; + expect(k.meta).toBeFalsy; }); it("returns from keyboard input Crtl+Space", () => { @@ -200,10 +199,10 @@ describe("#keyFromKeyboardEvent", () => { metaKey: false, }) ); - expect(k.key).to.equal("Space"); - expect(k.shift).to.be.false; - expect(k.ctrl).to.be.true; - expect(k.alt).to.be.false; - expect(k.meta).to.be.false; + expect(k.key).toEqual("Space"); + expect(k.shift).toBeFalsy; + expect(k.ctrl).toBeTruthy; + expect(k.alt).toBeFalsy; + expect(k.meta).toBeFalsy; }); }); diff --git a/test/content/domains/KeySequence.test.ts b/test/content/domains/KeySequence.test.ts index 1d1debe..683f592 100644 --- a/test/content/domains/KeySequence.test.ts +++ b/test/content/domains/KeySequence.test.ts @@ -1,5 +1,4 @@ import KeySequence from "../../../src/content/domains/KeySequence"; -import { expect } from "chai"; import Key from "../../../src/shared/settings/Key"; describe("KeySequence", () => { @@ -9,9 +8,9 @@ describe("KeySequence", () => { seq.push(Key.fromMapKey("g")); seq.push(Key.fromMapKey("")); - expect(seq.keys[0].key).to.equal("g"); - expect(seq.keys[1].key).to.equal("U"); - expect(seq.keys[1].shift).to.be.true; + expect(seq.keys[0].key).toEqual("g"); + expect(seq.keys[1].key).toEqual("U"); + expect(seq.keys[1].shift).toBeTruthy; }); }); @@ -22,13 +21,13 @@ describe("KeySequence", () => { Key.fromMapKey(""), ]); - expect(seq.startsWith(new KeySequence([]))).to.be.true; - expect(seq.startsWith(new KeySequence([Key.fromMapKey("g")]))).to.be.true; + expect(seq.startsWith(new KeySequence([]))).toBeTruthy; + expect(seq.startsWith(new KeySequence([Key.fromMapKey("g")]))).toBeTruthy; expect( seq.startsWith( new KeySequence([Key.fromMapKey("g"), Key.fromMapKey("")]) ) - ).to.be.true; + ).toBeTruthy; expect( seq.startsWith( new KeySequence([ @@ -37,17 +36,15 @@ describe("KeySequence", () => { Key.fromMapKey("x"), ]) ) - ).to.be.false; - expect(seq.startsWith(new KeySequence([Key.fromMapKey("h")]))).to.be - .false; + ).toBeFalsy; + expect(seq.startsWith(new KeySequence([Key.fromMapKey("h")]))).toBeFalsy; }); it("returns true if the empty sequence starts with an empty sequence", () => { const seq = new KeySequence([]); - expect(seq.startsWith(new KeySequence([]))).to.be.true; - expect(seq.startsWith(new KeySequence([Key.fromMapKey("h")]))).to.be - .false; + expect(seq.startsWith(new KeySequence([]))).toBeTruthy; + expect(seq.startsWith(new KeySequence([Key.fromMapKey("h")]))).toBeFalsy; }); }); @@ -58,14 +55,14 @@ describe("KeySequence", () => { new Key({ key: "4" }), new Key({ key: "0" }), ]).isDigitOnly() - ).to.be.true; + ).toBeTruthy; expect( new KeySequence([ new Key({ key: "4" }), new Key({ key: "0" }), new Key({ key: "z" }), ]).isDigitOnly() - ).to.be.false; + ).toBeFalsy; }); }); @@ -77,7 +74,7 @@ describe("KeySequence", () => { new Key({ key: "g" }), new Key({ key: "g" }), ]); - expect(seq.repeatCount()).to.equal(10); + expect(seq.repeatCount()).toEqual(10); seq = new KeySequence([ new Key({ key: "0" }), @@ -85,23 +82,23 @@ describe("KeySequence", () => { new Key({ key: "g" }), new Key({ key: "g" }), ]); - expect(seq.repeatCount()).to.equal(5); + expect(seq.repeatCount()).toEqual(5); }); it("returns 1 if no numeric prefix", () => { let seq = new KeySequence([new Key({ key: "g" }), new Key({ key: "g" })]); - expect(seq.repeatCount()).to.equal(1); + expect(seq.repeatCount()).toEqual(1); seq = new KeySequence([]); - expect(seq.repeatCount()).to.equal(1); + expect(seq.repeatCount()).toEqual(1); }); it("returns whole keys if digits only sequence", () => { let seq = new KeySequence([new Key({ key: "1" }), new Key({ key: "0" })]); - expect(seq.repeatCount()).to.equal(10); + expect(seq.repeatCount()).toEqual(10); seq = new KeySequence([new Key({ key: "0" }), new Key({ key: "5" })]); - expect(seq.repeatCount()).to.equal(5); + expect(seq.repeatCount()).toEqual(5); }); }); @@ -114,7 +111,7 @@ describe("KeySequence", () => { new Key({ key: "g" }), new Key({ key: "3" }), ]).trimNumericPrefix(); - expect(seq.keys.map((key) => key.key)).to.deep.equal(["g", "g", "3"]); + expect(seq.keys.map((key) => key.key)).toEqual(["g", "g", "3"]); }); it("returns empty if keys contains only digis", () => { @@ -122,7 +119,7 @@ describe("KeySequence", () => { new Key({ key: "1" }), new Key({ key: "0" }), ]).trimNumericPrefix(); - expect(seq.trimNumericPrefix().keys).to.be.empty; + expect(seq.trimNumericPrefix().keys).toHaveLength(0); }); it("returns itself if no numeric prefix", () => { @@ -132,23 +129,21 @@ describe("KeySequence", () => { new Key({ key: "3" }), ]).trimNumericPrefix(); - expect(seq.keys.map((key) => key.key)).to.deep.equal(["g", "g", "3"]); + expect(seq.keys.map((key) => key.key)).toEqual(["g", "g", "3"]); }); }); describe("#splitNumericPrefix", () => { it("splits numeric prefix", () => { - expect( - KeySequence.fromMapKeys("10gg").splitNumericPrefix() - ).to.deep.equal([ + expect(KeySequence.fromMapKeys("10gg").splitNumericPrefix()).toEqual([ KeySequence.fromMapKeys("10"), KeySequence.fromMapKeys("gg"), ]); - expect(KeySequence.fromMapKeys("10").splitNumericPrefix()).to.deep.equal([ + expect(KeySequence.fromMapKeys("10").splitNumericPrefix()).toEqual([ KeySequence.fromMapKeys("10"), new KeySequence([]), ]); - expect(KeySequence.fromMapKeys("gg").splitNumericPrefix()).to.deep.equal([ + expect(KeySequence.fromMapKeys("gg").splitNumericPrefix()).toEqual([ new KeySequence([]), KeySequence.fromMapKeys("gg"), ]); @@ -158,22 +153,22 @@ describe("KeySequence", () => { describe("#fromMapKeys", () => { it("returns mapped keys for Shift+Esc", () => { const keys = KeySequence.fromMapKeys("").keys; - expect(keys).to.have.lengthOf(1); - expect(keys[0].key).to.equal("Esc"); - expect(keys[0].shift).to.be.true; + expect(keys).toHaveLength(1); + expect(keys[0].key).toEqual("Esc"); + expect(keys[0].shift).toBeTruthy; }); it("returns mapped keys for ad", () => { const keys = KeySequence.fromMapKeys("ad").keys; - expect(keys).to.have.lengthOf(5); - expect(keys[0].key).to.equal("a"); - expect(keys[1].ctrl).to.be.true; - expect(keys[1].key).to.equal("b"); - expect(keys[2].alt).to.be.true; - expect(keys[2].key).to.equal("c"); - expect(keys[3].key).to.equal("d"); - expect(keys[4].meta).to.be.true; - expect(keys[4].key).to.equal("e"); + expect(keys).toHaveLength(5); + expect(keys[0].key).toEqual("a"); + expect(keys[1].ctrl).toBeTruthy; + expect(keys[1].key).toEqual("b"); + expect(keys[2].alt).toBeTruthy; + expect(keys[2].key).toEqual("c"); + expect(keys[3].key).toEqual("d"); + expect(keys[4].meta).toBeTruthy; + expect(keys[4].key).toEqual("e"); }); }); }); diff --git a/test/content/operators/impls/AddonOperatorFactoryChain.test.ts b/test/content/operators/impls/AddonOperatorFactoryChain.test.ts index dde5a35..263104e 100644 --- a/test/content/operators/impls/AddonOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/AddonOperatorFactoryChain.test.ts @@ -3,7 +3,6 @@ import EnableAddonOperator from "../../../../src/content/operators/impls/EnableA import DisableAddonOperator from "../../../../src/content/operators/impls/DisableAddonOperator"; import ToggleAddonOperator from "../../../../src/content/operators/impls/ToggleAddonOperator"; import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient"; import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository"; import MockConsoleFramePresenter from "./MockConsoleFramePresenter"; @@ -16,16 +15,16 @@ describe("AddonOperatorFactoryChain", () => { new MockAddonEnabledRepository(), new MockConsoleFramePresenter(false) ); - expect(sut.create({ type: operations.ADDON_ENABLE }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.ADDON_ENABLE }, 0)).toBeInstanceOf( EnableAddonOperator ); - expect( - sut.create({ type: operations.ADDON_DISABLE }, 0) - ).to.be.instanceOf(DisableAddonOperator); + expect(sut.create({ type: operations.ADDON_DISABLE }, 0)).toBeInstanceOf( + DisableAddonOperator + ); expect( sut.create({ type: operations.ADDON_TOGGLE_ENABLED }, 0) - ).to.be.instanceOf(ToggleAddonOperator); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + ).toBeInstanceOf(ToggleAddonOperator); + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/BackgroundOperationOperator.test.ts b/test/content/operators/impls/BackgroundOperationOperator.test.ts index b8b1fbd..77efeb2 100644 --- a/test/content/operators/impls/BackgroundOperationOperator.test.ts +++ b/test/content/operators/impls/BackgroundOperationOperator.test.ts @@ -1,7 +1,6 @@ import * as operations from "../../../../src/shared/operations"; import BackgroundOperationOperator from "../../../../src/content/operators/impls/BackgroundOperationOperator"; import OperationClient from "../../../../src/content/client/OperationClient"; -import { expect } from "chai"; class MockOperationClient implements OperationClient { public readonly executedOps: { @@ -30,7 +29,7 @@ describe("BackgroundOperationOperator", () => { await sut.run(); - expect(client.executedOps).to.deep.equal([ + expect(client.executedOps).toEqual([ { op: { type: operations.TAB_CLOSE }, repeat: 2 }, ]); }); diff --git a/test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts b/test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts index 9ddc229..d4c61c4 100644 --- a/test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import ClipboardOperatorFactoryChain from "../../../../src/content/operators/impls/ClipboardOperatorFactoryChain"; import YankURLOperator from "../../../../src/content/operators/impls/YankURLOperator"; import PasteOperator from "../../../../src/content/operators/impls/PasteOperator"; @@ -19,13 +18,13 @@ describe("ClipboardOperatorFactoryChain", () => { new MockSettingRepository(), new MockURLRepository() ); - expect(sut.create({ type: operations.URLS_YANK }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.URLS_YANK }, 0)).toBeInstanceOf( YankURLOperator ); expect( sut.create({ type: operations.URLS_PASTE, newTab: false }, 0) - ).to.be.instanceOf(PasteOperator); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + ).toBeInstanceOf(PasteOperator); + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/DisableAddonOperator.test.ts b/test/content/operators/impls/DisableAddonOperator.test.ts index e05d1f1..bb137ac 100644 --- a/test/content/operators/impls/DisableAddonOperator.test.ts +++ b/test/content/operators/impls/DisableAddonOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import DisableAddonOperator from "../../../../src/content/operators/impls/DisableAddonOperator"; import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient"; import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository"; @@ -14,9 +13,9 @@ describe("DisableAddonOperator", () => { await sut.run(); - expect(client.enabled).to.be.false; - expect(repository.enabled).to.be.false; - expect(presenter.attached).to.be.false; + expect(client.enabled).toBeFalsy; + expect(repository.enabled).toBeFalsy; + expect(presenter.attached).toBeFalsy; }); }); }); diff --git a/test/content/operators/impls/EnableAddonOperator.test.ts b/test/content/operators/impls/EnableAddonOperator.test.ts index 6025608..cd838af 100644 --- a/test/content/operators/impls/EnableAddonOperator.test.ts +++ b/test/content/operators/impls/EnableAddonOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import EnableAddonOperator from "../../../../src/content/operators/impls/EnableAddonOperator"; import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient"; import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository"; @@ -14,9 +13,9 @@ describe("EnableAddonOperator", () => { await sut.run(); - expect(client.enabled).to.be.true; - expect(repository.enabled).to.be.true; - expect(presenter.attached).to.be.true; + expect(client.enabled).toBeTruthy; + expect(repository.enabled).toBeTruthy; + expect(presenter.attached).toBeTruthy; }); }); }); diff --git a/test/content/operators/impls/EnableJumpMarkOperator.test.ts b/test/content/operators/impls/EnableJumpMarkOperator.test.ts index 66b4ecd..f81d6dc 100644 --- a/test/content/operators/impls/EnableJumpMarkOperator.test.ts +++ b/test/content/operators/impls/EnableJumpMarkOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import EnableJumpMarkOperator from "../../../../src/content/operators/impls/EnableJumpMarkOperator"; import MockMarkKeyRepository from "../../mock/MockMarkKeyRepository"; @@ -13,7 +12,7 @@ describe("EnableJumpMarkOperator", () => { await sut.run(); - expect(repository.jumpMode).to.be.true; + expect(repository.jumpMode).toBeTruthy; }); }); }); diff --git a/test/content/operators/impls/EnableSetMarkOperator.test.ts b/test/content/operators/impls/EnableSetMarkOperator.test.ts index b28874d..33ce2ba 100644 --- a/test/content/operators/impls/EnableSetMarkOperator.test.ts +++ b/test/content/operators/impls/EnableSetMarkOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import EnableSetMarkOperator from "../../../../src/content/operators/impls/EnableSetMarkOperator"; import MockMarkKeyRepository from "../../mock/MockMarkKeyRepository"; @@ -13,7 +12,7 @@ describe("EnableSetMarkOperator", () => { await sut.run(); - expect(repository.setMode).to.be.true; + expect(repository.setMode).toBeTruthy; }); }); }); diff --git a/test/content/operators/impls/FocusOperatorFactoryChain.test.ts b/test/content/operators/impls/FocusOperatorFactoryChain.test.ts index 91f734b..84a4a52 100644 --- a/test/content/operators/impls/FocusOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/FocusOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import FocusOperatorFactoryChain from "../../../../src/content/operators/impls/FocusOperatorFactoryChain"; import FocusOperator from "../../../../src/content/operators/impls/FocusOperator"; import MockFocusPresenter from "../../mock/MockFocusPresenter"; @@ -8,10 +7,10 @@ describe("FocusOperatorFactoryChain", () => { describe("#create", () => { it("returns an operator", () => { const sut = new FocusOperatorFactoryChain(new MockFocusPresenter()); - expect(sut.create({ type: operations.FOCUS_INPUT }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.FOCUS_INPUT }, 0)).toBeInstanceOf( FocusOperator ); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/FollowOperatorFactoryChain.test.ts b/test/content/operators/impls/FollowOperatorFactoryChain.test.ts index 91f734b..84a4a52 100644 --- a/test/content/operators/impls/FollowOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/FollowOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import FocusOperatorFactoryChain from "../../../../src/content/operators/impls/FocusOperatorFactoryChain"; import FocusOperator from "../../../../src/content/operators/impls/FocusOperator"; import MockFocusPresenter from "../../mock/MockFocusPresenter"; @@ -8,10 +7,10 @@ describe("FocusOperatorFactoryChain", () => { describe("#create", () => { it("returns an operator", () => { const sut = new FocusOperatorFactoryChain(new MockFocusPresenter()); - expect(sut.create({ type: operations.FOCUS_INPUT }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.FOCUS_INPUT }, 0)).toBeInstanceOf( FocusOperator ); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/HorizontalScrollOperator.test.ts b/test/content/operators/impls/HorizontalScrollOperator.test.ts index f77a34e..abe6856 100644 --- a/test/content/operators/impls/HorizontalScrollOperator.test.ts +++ b/test/content/operators/impls/HorizontalScrollOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import HorizontalScrollOperator from "../../../../src/content/operators/impls/HorizontalScrollOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("HorizontalScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 1, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 1, y: 0 }); }); it("scroll horizontally with repeats", async () => { @@ -22,7 +21,7 @@ describe("HorizontalScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 5, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 5, y: 0 }); }); }); }); diff --git a/test/content/operators/impls/MarkOperatorFactoryChain.test.ts b/test/content/operators/impls/MarkOperatorFactoryChain.test.ts index 1f094dd..99cb756 100644 --- a/test/content/operators/impls/MarkOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/MarkOperatorFactoryChain.test.ts @@ -1,5 +1,4 @@ import * as operations from "../../../../src/shared/operations"; -import { expect } from "chai"; import MarkOperatorFactoryChain from "../../../../src/content/operators/impls/MarkOperatorFactoryChain"; import MockMarkKeyRepository from "../../mock/MockMarkKeyRepository"; import EnableSetMarkOperator from "../../../../src/content/operators/impls/EnableSetMarkOperator"; @@ -11,11 +10,11 @@ describe("MarkOperatorFactoryChain", () => { const sut = new MarkOperatorFactoryChain(new MockMarkKeyRepository()); expect( sut.create({ type: operations.MARK_SET_PREFIX }, 0) - ).to.be.instanceOf(EnableSetMarkOperator); + ).toBeInstanceOf(EnableSetMarkOperator); expect( sut.create({ type: operations.MARK_JUMP_PREFIX }, 0) - ).to.be.instanceOf(EnableJumpMarkOperator); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.null; + ).toBeInstanceOf(EnableJumpMarkOperator); + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeNull; }); }); }); diff --git a/test/content/operators/impls/PageScrollOperator.test.ts b/test/content/operators/impls/PageScrollOperator.test.ts index 80c9185..77d3a0f 100644 --- a/test/content/operators/impls/PageScrollOperator.test.ts +++ b/test/content/operators/impls/PageScrollOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import PageScrollOperator from "../../../../src/content/operators/impls/PageScrollOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("PageScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 1, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 1, y: 0 }); }); it("scroll by a page with repeats", async () => { @@ -22,7 +21,7 @@ describe("PageScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 5, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 5, y: 0 }); }); }); }); diff --git a/test/content/operators/impls/ScrollOperatorFactoryChain.test.ts b/test/content/operators/impls/ScrollOperatorFactoryChain.test.ts index 08034cb..3ba204a 100644 --- a/test/content/operators/impls/ScrollOperatorFactoryChain.test.ts +++ b/test/content/operators/impls/ScrollOperatorFactoryChain.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollOperatorFactoryChain from "../../../../src/content/operators/impls/ScrollOperatorFactoryChain"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -20,27 +19,27 @@ describe("ScrollOperatorFactoryChain", () => { ); expect( sut.create({ type: operations.SCROLL_HORIZONALLY, count: 10 }, 0) - ).to.be.instanceOf(HorizontalScrollOperator); + ).toBeInstanceOf(HorizontalScrollOperator); expect( sut.create({ type: operations.SCROLL_VERTICALLY, count: 10 }, 0) - ).to.be.instanceOf(VerticalScrollOperator); + ).toBeInstanceOf(VerticalScrollOperator); expect( sut.create({ type: operations.SCROLL_PAGES, count: 10 }, 0) - ).to.be.instanceOf(PageScrollOperator); - expect(sut.create({ type: operations.SCROLL_TOP }, 0)).to.be.instanceOf( + ).toBeInstanceOf(PageScrollOperator); + expect(sut.create({ type: operations.SCROLL_TOP }, 0)).toBeInstanceOf( ScrollToTopOperator ); - expect( - sut.create({ type: operations.SCROLL_BOTTOM }, 0) - ).to.be.instanceOf(ScrollToBottomOperator); - expect(sut.create({ type: operations.SCROLL_HOME }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.SCROLL_BOTTOM }, 0)).toBeInstanceOf( + ScrollToBottomOperator + ); + expect(sut.create({ type: operations.SCROLL_HOME }, 0)).toBeInstanceOf( ScrollToHomeOperator ); - expect(sut.create({ type: operations.SCROLL_END }, 0)).to.be.instanceOf( + expect(sut.create({ type: operations.SCROLL_END }, 0)).toBeInstanceOf( ScrollToEndOperator ); - expect(sut.create({ type: operations.PAGE_HOME, newTab: false }, 0)).to.be - .null; + expect(sut.create({ type: operations.PAGE_HOME, newTab: false }, 0)) + .toBeNull; }); }); }); diff --git a/test/content/operators/impls/ScrollToBottomOperator.test.ts b/test/content/operators/impls/ScrollToBottomOperator.test.ts index 500c8f2..f369227 100644 --- a/test/content/operators/impls/ScrollToBottomOperator.test.ts +++ b/test/content/operators/impls/ScrollToBottomOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollToBottomOperator from "../../../../src/content/operators/impls/ScrollToBottomOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("ScrollToBottomOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 0, y: Infinity }); + expect(presenter.getScroll()).toEqual({ x: 0, y: Infinity }); }); }); }); diff --git a/test/content/operators/impls/ScrollToEndOperator.test.ts b/test/content/operators/impls/ScrollToEndOperator.test.ts index 0c98c8d..304d914 100644 --- a/test/content/operators/impls/ScrollToEndOperator.test.ts +++ b/test/content/operators/impls/ScrollToEndOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollToEndOperator from "../../../../src/content/operators/impls/ScrollToEndOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("ScrollToEndOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: Infinity, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: Infinity, y: 0 }); }); }); }); diff --git a/test/content/operators/impls/ScrollToHomeOperator.test.ts b/test/content/operators/impls/ScrollToHomeOperator.test.ts index f8614d2..e09c16a 100644 --- a/test/content/operators/impls/ScrollToHomeOperator.test.ts +++ b/test/content/operators/impls/ScrollToHomeOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollToHomeOperator from "../../../../src/content/operators/impls/ScrollToHomeOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("ScrollToHomeOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 0, y: 10 }); + expect(presenter.getScroll()).toEqual({ x: 0, y: 10 }); }); }); }); diff --git a/test/content/operators/impls/ScrollToTopOperator.test.ts b/test/content/operators/impls/ScrollToTopOperator.test.ts index 25a84ba..7337bea 100644 --- a/test/content/operators/impls/ScrollToTopOperator.test.ts +++ b/test/content/operators/impls/ScrollToTopOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ScrollToTopOperator from "../../../../src/content/operators/impls/ScrollToTopOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("ScrollToTopOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 10, y: 0 }); + expect(presenter.getScroll()).toEqual({ x: 10, y: 0 }); }); }); }); diff --git a/test/content/operators/impls/ToggleAddonOperator.test.ts b/test/content/operators/impls/ToggleAddonOperator.test.ts index 1f291b5..cc77429 100644 --- a/test/content/operators/impls/ToggleAddonOperator.test.ts +++ b/test/content/operators/impls/ToggleAddonOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import ToggleAddonOperator from "../../../../src/content/operators/impls/ToggleAddonOperator"; import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient"; import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository"; @@ -14,15 +13,15 @@ describe("ToggleAddonOperator", () => { await sut.run(); - expect(client.enabled).to.be.false; - expect(repository.enabled).to.be.false; - expect(presenter.attached).to.be.false; + expect(client.enabled).toBeFalsy; + expect(repository.enabled).toBeFalsy; + expect(presenter.attached).toBeFalsy; await sut.run(); - expect(client.enabled).to.be.true; - expect(repository.enabled).to.be.true; - expect(presenter.attached).to.be.true; + expect(client.enabled).toBeTruthy; + expect(repository.enabled).toBeTruthy; + expect(presenter.attached).toBeTruthy; }); }); }); diff --git a/test/content/operators/impls/VerticalScrollOperator.test.ts b/test/content/operators/impls/VerticalScrollOperator.test.ts index 05b15d2..1b87060 100644 --- a/test/content/operators/impls/VerticalScrollOperator.test.ts +++ b/test/content/operators/impls/VerticalScrollOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import VerticalScrollOperator from "../../../../src/content/operators/impls/VerticalScrollOperator"; import MockScrollPresenter from "../../mock/MockScrollPresenter"; import MockSettingRepository from "../../mock/MockSettingRepository"; @@ -12,7 +11,7 @@ describe("VerticalScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 0, y: 1 }); + expect(presenter.getScroll()).toEqual({ x: 0, y: 1 }); }); it("scroll vertically with repeats", async () => { @@ -22,7 +21,7 @@ describe("VerticalScrollOperator", () => { await sut.run(); - expect(presenter.getScroll()).to.deep.equal({ x: 0, y: 5 }); + expect(presenter.getScroll()).toEqual({ x: 0, y: 5 }); }); }); }); diff --git a/test/content/operators/impls/YankURLOperator.test.ts b/test/content/operators/impls/YankURLOperator.test.ts index 46e3d06..3db28bf 100644 --- a/test/content/operators/impls/YankURLOperator.test.ts +++ b/test/content/operators/impls/YankURLOperator.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import MockClipboardRepository from "../../mock/MockClipboardRepository"; import YankURLOperator from "../../../../src/content/operators/impls/YankURLOperator"; import MockURLRepository from "../../mock/MockURLRepository"; @@ -18,9 +17,9 @@ describe("YankOperation", () => { await sut.run(); - expect(clipboardRepository.read()).to.equal("https://example.com/"); - expect(consoleClient.text).to.equal("Yanked https://example.com/"); - expect(consoleClient.isError).to.be.false; + expect(clipboardRepository.read()).toEqual("https://example.com/"); + expect(consoleClient.text).toEqual("Yanked https://example.com/"); + expect(consoleClient.isError).toBeFalsy; }); }); }); diff --git a/test/content/presenters/Hint.test.ts b/test/content/presenters/Hint.test.ts index 0823bdc..b3b2d19 100644 --- a/test/content/presenters/Hint.test.ts +++ b/test/content/presenters/Hint.test.ts @@ -6,7 +6,6 @@ import AbstractHint, { LinkHint, InputHint, } from "../../../src/content/presenters/Hint"; -import { expect } from "chai"; class Hint extends AbstractHint {} @@ -21,7 +20,7 @@ describe("Hint", () => { new Hint(link, "abc"); const elem = document.querySelector(".vimvixen-hint"); - expect(elem!.textContent!.trim()).to.be.equal("abc"); + expect(elem!.textContent!.trim()).toEqual("abc"); }); }); @@ -33,7 +32,7 @@ describe("Hint", () => { hint.show(); const elem = document.querySelector(".vimvixen-hint") as HTMLElement; - expect(elem.style.display).to.not.equal("none"); + expect(elem.style.display).not.toEqual("none"); }); }); @@ -44,7 +43,7 @@ describe("Hint", () => { hint.hide(); const elem = document.querySelector(".vimvixen-hint") as HTMLElement; - expect(elem.style.display).to.equal("none"); + expect(elem.style.display).toEqual("none"); }); }); @@ -54,9 +53,9 @@ describe("Hint", () => { const hint = new Hint(link, "abc"); const elem = document.querySelector(".vimvixen-hint")!; - expect(elem.parentElement).to.not.be.null; + expect(elem.parentElement).not.toBeNull; hint.remove(); - expect(elem.parentElement).to.be.null; + expect(elem.parentElement).toBeNull; }); }); }); @@ -75,7 +74,7 @@ describe("LinkHint", () => { const link = document.getElementById("test-link1") as HTMLAnchorElement; const hint = new LinkHint(link, "abc"); - expect(hint.getLink()).to.equal("https://google.com/"); + expect(hint.getLink()).toEqual("https://google.com/"); }); }); @@ -84,12 +83,12 @@ describe("LinkHint", () => { let link = document.getElementById("test-link1") as HTMLAnchorElement; let hint = new LinkHint(link, "abc"); - expect(hint.getLinkTarget()).to.be.null; + expect(hint.getLinkTarget()).toBeNull; link = document.getElementById("test-link2") as HTMLAnchorElement; hint = new LinkHint(link, "abc"); - expect(hint.getLinkTarget()).to.equal("_blank"); + expect(hint.getLinkTarget()).toEqual("_blank"); }); }); @@ -118,7 +117,7 @@ describe("InputHint", () => { const hint = new InputHint(input, "abc"); hint.activate(); - expect(document.activeElement).to.equal(input); + expect(document.activeElement).toEqual(input); }); }); @@ -132,7 +131,7 @@ describe("InputHint", () => { const hint = new InputHint(input, "abc"); hint.activate(); - expect(input.checked).to.be.true; + expect(input.checked).toBeTruthy; }); }); describe("