aboutsummaryrefslogtreecommitdiff
path: root/test/content/usecases/KeymapUseCase.test.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2021-09-26 17:01:31 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2021-09-26 17:23:14 +0900
commite304581fb15eabb3a973d363a282ee7546561e01 (patch)
tree1afb21a2dee2ada3d10c1417fa61c0aae1f83077 /test/content/usecases/KeymapUseCase.test.ts
parent11d6d725eee2ac0a1c16e4c7a4ce4f296bb6b016 (diff)
Do not use chai on unit test
Diffstat (limited to 'test/content/usecases/KeymapUseCase.test.ts')
-rw-r--r--test/content/usecases/KeymapUseCase.test.ts89
1 files changed, 44 insertions, 45 deletions
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;
});
});
});