aboutsummaryrefslogtreecommitdiff
path: root/test/content/domains
diff options
context:
space:
mode:
Diffstat (limited to 'test/content/domains')
-rw-r--r--test/content/domains/KeySequence.test.ts77
1 files changed, 36 insertions, 41 deletions
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");
});
});
});