aboutsummaryrefslogtreecommitdiff
path: root/test/content
diff options
context:
space:
mode:
Diffstat (limited to 'test/content')
-rw-r--r--test/content/InputDriver.test.ts67
-rw-r--r--test/content/domains/KeySequence.test.ts77
-rw-r--r--test/content/operators/impls/AddonOperatorFactoryChain.test.ts13
-rw-r--r--test/content/operators/impls/BackgroundOperationOperator.test.ts3
-rw-r--r--test/content/operators/impls/ClipboardOperatorFactoryChain.test.ts7
-rw-r--r--test/content/operators/impls/DisableAddonOperator.test.ts7
-rw-r--r--test/content/operators/impls/EnableAddonOperator.test.ts7
-rw-r--r--test/content/operators/impls/EnableJumpMarkOperator.test.ts3
-rw-r--r--test/content/operators/impls/EnableSetMarkOperator.test.ts3
-rw-r--r--test/content/operators/impls/FocusOperatorFactoryChain.test.ts5
-rw-r--r--test/content/operators/impls/FollowOperatorFactoryChain.test.ts5
-rw-r--r--test/content/operators/impls/HorizontalScrollOperator.test.ts5
-rw-r--r--test/content/operators/impls/MarkOperatorFactoryChain.test.ts7
-rw-r--r--test/content/operators/impls/PageScrollOperator.test.ts5
-rw-r--r--test/content/operators/impls/ScrollOperatorFactoryChain.test.ts23
-rw-r--r--test/content/operators/impls/ScrollToBottomOperator.test.ts3
-rw-r--r--test/content/operators/impls/ScrollToEndOperator.test.ts3
-rw-r--r--test/content/operators/impls/ScrollToHomeOperator.test.ts3
-rw-r--r--test/content/operators/impls/ScrollToTopOperator.test.ts3
-rw-r--r--test/content/operators/impls/ToggleAddonOperator.test.ts13
-rw-r--r--test/content/operators/impls/VerticalScrollOperator.test.ts5
-rw-r--r--test/content/operators/impls/YankURLOperator.test.ts7
-rw-r--r--test/content/presenters/Hint.test.ts23
-rw-r--r--test/content/presenters/NavigationPresenter.test.ts3
-rw-r--r--test/content/repositories/AddonEnabledRepository.test.ts5
-rw-r--r--test/content/repositories/FollowKeyRepository.test.ts9
-rw-r--r--test/content/repositories/FollowMasterRepository.test.ts23
-rw-r--r--test/content/repositories/FollowSlaveRepository.test.ts7
-rw-r--r--test/content/repositories/KeymapRepository.test.ts9
-rw-r--r--test/content/repositories/MarkKeyRepository.test.ts13
-rw-r--r--test/content/repositories/MarkRepository.test.ts5
-rw-r--r--test/content/repositories/SettingRepository.test.ts3
-rw-r--r--test/content/usecases/AddonEnabledUseCase.test.ts29
-rw-r--r--test/content/usecases/HintKeyProducer.test.ts13
-rw-r--r--test/content/usecases/KeymapUseCase.test.ts89
-rw-r--r--test/content/usecases/MarkUseCase.test.ts15
-rw-r--r--test/content/usecases/SettingUseCaase.test.ts5
37 files changed, 242 insertions, 283 deletions
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");
});
});
});