aboutsummaryrefslogtreecommitdiff
path: root/test/shared
diff options
context:
space:
mode:
Diffstat (limited to 'test/shared')
-rw-r--r--test/shared/SettingData.test.ts25
-rw-r--r--test/shared/operations.test.ts15
-rw-r--r--test/shared/settings/Blacklist.test.ts83
-rw-r--r--test/shared/settings/Key.test.ts95
-rw-r--r--test/shared/settings/Keymaps.test.ts13
-rw-r--r--test/shared/settings/Properties.test.ts5
-rw-r--r--test/shared/settings/Search.test.ts15
-rw-r--r--test/shared/settings/Settings.test.ts15
-rw-r--r--test/shared/urls.test.ts33
9 files changed, 145 insertions, 154 deletions
diff --git a/test/shared/SettingData.test.ts b/test/shared/SettingData.test.ts
index 3cfd5c9..f2c4aa9 100644
--- a/test/shared/SettingData.test.ts
+++ b/test/shared/SettingData.test.ts
@@ -4,7 +4,6 @@ import SettingData, {
FormSettings,
} from "../../src/shared/SettingData";
import Settings from "../../src/shared/settings/Settings";
-import { expect } from "chai";
import Keymaps from "../../src/shared/settings/Keymaps";
import ColorScheme from "../../src/shared/ColorScheme";
@@ -18,7 +17,7 @@ describe("shared/SettingData", () => {
};
const keymaps = FormKeymaps.fromJSON(data).toKeymaps().toJSON();
- expect(keymaps).to.deep.equal({
+ expect(keymaps).toEqual({
j: { type: "scroll.vertically", count: 1 },
"0": { type: "scroll.home" },
});
@@ -33,7 +32,7 @@ describe("shared/SettingData", () => {
});
const form = FormKeymaps.fromKeymaps(keymaps).toJSON();
- expect(form).to.deep.equal({
+ expect(form).toEqual({
'scroll.vertically?{"count":1}': "j",
"scroll.home": "0",
});
@@ -62,7 +61,7 @@ describe("shared/SettingData", () => {
}`;
const settings = JSONTextSettings.fromText(o).toSettings();
- expect(settings.toJSON()).to.deep.equal(JSON.parse(o));
+ expect(settings.toJSON()).toEqual(JSON.parse(o));
});
});
@@ -85,7 +84,7 @@ describe("shared/SettingData", () => {
});
const json = JSONTextSettings.fromSettings(o).toJSONText();
- expect(JSON.parse(json)).to.deep.equal(o.toJSON());
+ expect(JSON.parse(json)).toEqual(o.toJSON());
});
});
});
@@ -112,7 +111,7 @@ describe("shared/SettingData", () => {
};
const settings = FormSettings.fromJSON(data).toSettings();
- expect(settings.toJSON()).to.deep.equal({
+ expect(settings.toJSON()).toEqual({
keymaps: {
j: { type: "scroll.vertically", count: 1 },
"0": { type: "scroll.home" },
@@ -157,7 +156,7 @@ describe("shared/SettingData", () => {
});
const json = FormSettings.fromSettings(data).toJSON();
- expect(json).to.deep.equal({
+ expect(json).toEqual({
keymaps: {
'scroll.vertically?{"count":1}': "j",
"scroll.home": "0",
@@ -202,8 +201,8 @@ describe("shared/SettingData", () => {
};
const j = SettingData.fromJSON(data).toJSON();
- expect(j.source).to.equal("json");
- expect(j.json).to.be.a("string");
+ expect(j.source).toEqual("json");
+ expect(typeof j.json).toEqual("string");
});
it("parse object from form source", () => {
@@ -226,8 +225,8 @@ describe("shared/SettingData", () => {
};
const j = SettingData.fromJSON(data).toJSON();
- expect(j.source).to.equal("form");
- expect(j.form).to.deep.equal({
+ expect(j.source).toEqual("form");
+ expect(j.form).toEqual({
keymaps: {},
search: {
default: "yahoo",
@@ -266,7 +265,7 @@ describe("shared/SettingData", () => {
};
const settings = SettingData.fromJSON(data).toSettings();
- expect(settings.search.defaultEngine).to.equal("google");
+ expect(settings.search.defaultEngine).toEqual("google");
});
it("parse object from form source", () => {
@@ -288,7 +287,7 @@ describe("shared/SettingData", () => {
};
const settings = SettingData.fromJSON(data).toSettings();
- expect(settings.search.defaultEngine).to.equal("yahoo");
+ expect(settings.search.defaultEngine).toEqual("yahoo");
});
});
});
diff --git a/test/shared/operations.test.ts b/test/shared/operations.test.ts
index 449b25e..9fa9e19 100644
--- a/test/shared/operations.test.ts
+++ b/test/shared/operations.test.ts
@@ -1,5 +1,4 @@
import * as operations from "../../src/shared/operations";
-import { expect } from "chai";
describe("operations", () => {
describe("#valueOf", () => {
@@ -8,8 +7,8 @@ describe("operations", () => {
type: operations.SCROLL_VERTICALLY,
count: 10,
}) as operations.ScrollVerticallyOperation;
- expect(op.type).to.equal(operations.SCROLL_VERTICALLY);
- expect(op.count).to.equal(10);
+ expect(op.type).toEqual(operations.SCROLL_VERTICALLY);
+ expect(op.count).toEqual(10);
});
it("throws an Error on missing required parameter", () => {
@@ -17,7 +16,7 @@ describe("operations", () => {
operations.valueOf({
type: operations.SCROLL_VERTICALLY,
})
- ).to.throw(TypeError);
+ ).toThrow(TypeError);
});
it("fills default valus of optional parameter", () => {
@@ -25,8 +24,8 @@ describe("operations", () => {
type: operations.COMMAND_SHOW_OPEN,
}) as operations.CommandShowOpenOperation;
- expect(op.type).to.equal(operations.COMMAND_SHOW_OPEN);
- expect(op.alter).to.be.false;
+ expect(op.type).toEqual(operations.COMMAND_SHOW_OPEN);
+ expect(op.alter).toBeFalsy;
});
it("throws an Error on mismatch of parameter", () => {
@@ -35,14 +34,14 @@ describe("operations", () => {
type: operations.SCROLL_VERTICALLY,
count: "10",
})
- ).to.throw(TypeError);
+ ).toThrow(TypeError);
expect(() =>
operations.valueOf({
type: operations.COMMAND_SHOW_OPEN,
alter: "true",
})
- ).to.throw(TypeError);
+ ).toThrow(TypeError);
});
});
});
diff --git a/test/shared/settings/Blacklist.test.ts b/test/shared/settings/Blacklist.test.ts
index 1ccb32a..af7b946 100644
--- a/test/shared/settings/Blacklist.test.ts
+++ b/test/shared/settings/Blacklist.test.ts
@@ -1,15 +1,14 @@
import Blacklist, {
BlacklistItem,
} from "../../../src/shared/settings/Blacklist";
-import { expect } from "chai";
import Key from "../../../src/shared/settings/Key";
describe("BlacklistItem", () => {
describe("#fromJSON", () => {
it("parses string pattern", () => {
const item = BlacklistItem.fromJSON("example.com");
- expect(item.pattern).to.equal("example.com");
- expect(item.partial).to.be.false;
+ expect(item.pattern).toEqual("example.com");
+ expect(item.partial).toBeFalsy;
});
it("parses partial blacklist item", () => {
@@ -17,56 +16,56 @@ describe("BlacklistItem", () => {
url: "example.com",
keys: ["j", "k"],
});
- expect(item.pattern).to.equal("example.com");
- expect(item.partial).to.be.true;
- expect(item.keys).to.deep.equal(["j", "k"]);
+ expect(item.pattern).toEqual("example.com");
+ expect(item.partial).toBeTruthy;
+ expect(item.keys).toEqual(["j", "k"]);
});
});
describe("#matches", () => {
it('matches by "*"', () => {
const item = BlacklistItem.fromJSON("*");
- expect(item.matches(new URL("https://github.com/abc"))).to.be.true;
+ expect(item.matches(new URL("https://github.com/abc"))).toBeTruthy;
});
it("matches by hostname", () => {
const item = BlacklistItem.fromJSON("github.com");
- expect(item.matches(new URL("https://github.com"))).to.be.true;
- expect(item.matches(new URL("https://gist.github.com"))).to.be.false;
- expect(item.matches(new URL("https://github.com/ueokande"))).to.be.true;
- expect(item.matches(new URL("https://github.org"))).to.be.false;
- expect(item.matches(new URL("https://google.com/search?q=github.org"))).to
- .be.false;
+ expect(item.matches(new URL("https://github.com"))).toBeTruthy;
+ expect(item.matches(new URL("https://gist.github.com"))).toBeFalsy;
+ expect(item.matches(new URL("https://github.com/ueokande"))).toBeTruthy;
+ expect(item.matches(new URL("https://github.org"))).toBeFalsy;
+ expect(item.matches(new URL("https://google.com/search?q=github.org")))
+ .toBeFalsy;
});
it("matches by hostname with wildcard", () => {
const item = BlacklistItem.fromJSON("*.github.com");
- expect(item.matches(new URL("https://github.com"))).to.be.false;
- expect(item.matches(new URL("https://gist.github.com"))).to.be.true;
+ expect(item.matches(new URL("https://github.com"))).toBeFalsy;
+ expect(item.matches(new URL("https://gist.github.com"))).toBeTruthy;
});
it("matches by path", () => {
const item = BlacklistItem.fromJSON("github.com/abc");
- expect(item.matches(new URL("https://github.com/abc"))).to.be.true;
- expect(item.matches(new URL("https://github.com/abcdef"))).to.be.false;
- expect(item.matches(new URL("https://gist.github.com/abc"))).to.be.false;
+ expect(item.matches(new URL("https://github.com/abc"))).toBeTruthy;
+ expect(item.matches(new URL("https://github.com/abcdef"))).toBeFalsy;
+ expect(item.matches(new URL("https://gist.github.com/abc"))).toBeFalsy;
});
it("matches by path with wildcard", () => {
const item = BlacklistItem.fromJSON("github.com/abc*");
- expect(item.matches(new URL("https://github.com/abc"))).to.be.true;
- expect(item.matches(new URL("https://github.com/abcdef"))).to.be.true;
- expect(item.matches(new URL("https://gist.github.com/abc"))).to.be.false;
+ expect(item.matches(new URL("https://github.com/abc"))).toBeTruthy;
+ expect(item.matches(new URL("https://github.com/abcdef"))).toBeTruthy;
+ expect(item.matches(new URL("https://gist.github.com/abc"))).toBeFalsy;
});
it("matches address and port", () => {
const item = BlacklistItem.fromJSON("127.0.0.1:8888");
- expect(item.matches(new URL("http://127.0.0.1:8888/"))).to.be.true;
- expect(item.matches(new URL("http://127.0.0.1:8888/hello"))).to.be.true;
+ expect(item.matches(new URL("http://127.0.0.1:8888/"))).toBeTruthy;
+ expect(item.matches(new URL("http://127.0.0.1:8888/hello"))).toBeTruthy;
});
it("matches with partial blacklist", () => {
@@ -75,8 +74,8 @@ describe("BlacklistItem", () => {
keys: ["j", "k"],
});
- expect(item.matches(new URL("https://google.com"))).to.be.true;
- expect(item.matches(new URL("https://yahoo.com"))).to.be.false;
+ expect(item.matches(new URL("https://google.com"))).toBeTruthy;
+ expect(item.matches(new URL("https://yahoo.com"))).toBeFalsy;
});
});
@@ -89,22 +88,22 @@ describe("BlacklistItem", () => {
expect(
item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("j"))
- ).to.be.true;
+ ).toBeTruthy;
expect(
item.includeKey(
new URL("http://google.com/maps"),
Key.fromMapKey("<C-U>")
)
- ).to.be.true;
+ ).toBeTruthy;
expect(
item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("z"))
- ).to.be.false;
+ ).toBeFalsy;
expect(
item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("u"))
- ).to.be.false;
+ ).toBeFalsy;
expect(
item.includeKey(new URL("http://maps.google.com/"), Key.fromMapKey("j"))
- ).to.be.false;
+ ).toBeFalsy;
});
});
});
@@ -113,7 +112,7 @@ describe("Blacklist", () => {
describe("#fromJSON", () => {
it("parses string list", () => {
const blacklist = Blacklist.fromJSON(["example.com", "example.org"]);
- expect(blacklist.toJSON()).to.deep.equals(["example.com", "example.org"]);
+ expect(blacklist.toJSON()).toEqual(["example.com", "example.org"]);
});
it("parses mixed blacklist", () => {
@@ -121,7 +120,7 @@ describe("Blacklist", () => {
{ url: "example.com", keys: ["j", "k"] },
"example.org",
]);
- expect(blacklist.toJSON()).to.deep.equals([
+ expect(blacklist.toJSON()).toEqual([
{ url: "example.com", keys: ["j", "k"] },
"example.org",
]);
@@ -129,7 +128,7 @@ describe("Blacklist", () => {
it("parses empty blacklist", () => {
const blacklist = Blacklist.fromJSON([]);
- expect(blacklist.toJSON()).to.deep.equals([]);
+ expect(blacklist.toJSON()).toEqual([]);
});
});
@@ -137,12 +136,12 @@ describe("Blacklist", () => {
it("matches a url with entire blacklist", () => {
const blacklist = Blacklist.fromJSON(["google.com", "*.github.com"]);
expect(blacklist.includesEntireBlacklist(new URL("https://google.com")))
- .to.be.true;
+ .toBeTruthy;
expect(blacklist.includesEntireBlacklist(new URL("https://github.com")))
- .to.be.false;
+ .toBeFalsy;
expect(
blacklist.includesEntireBlacklist(new URL("https://gist.github.com"))
- ).to.be.true;
+ ).toBeTruthy;
});
it("does not matches with partial blacklist", () => {
@@ -151,9 +150,9 @@ describe("Blacklist", () => {
{ url: "yahoo.com", keys: ["j", "k"] },
]);
expect(blacklist.includesEntireBlacklist(new URL("https://google.com")))
- .to.be.true;
- expect(blacklist.includesEntireBlacklist(new URL("https://yahoo.com"))).to
- .be.false;
+ .toBeTruthy;
+ expect(blacklist.includesEntireBlacklist(new URL("https://yahoo.com")))
+ .toBeFalsy;
});
});
@@ -166,13 +165,13 @@ describe("Blacklist", () => {
expect(
blacklist.includeKey(new URL("https://google.com"), Key.fromMapKey("j"))
- ).to.be.false;
+ ).toBeFalsy;
expect(
blacklist.includeKey(new URL("https://github.com"), Key.fromMapKey("j"))
- ).to.be.true;
+ ).toBeTruthy;
expect(
blacklist.includeKey(new URL("https://github.com"), Key.fromMapKey("a"))
- ).to.be.false;
+ ).toBeFalsy;
});
});
});
diff --git a/test/shared/settings/Key.test.ts b/test/shared/settings/Key.test.ts
index 47af1d9..8ad9265 100644
--- a/test/shared/settings/Key.test.ts
+++ b/test/shared/settings/Key.test.ts
@@ -1,89 +1,88 @@
-import { expect } from "chai";
import Key from "../../../src/shared/settings/Key";
describe("Key", () => {
describe("fromMapKey", () => {
it("return for X", () => {
const key = Key.fromMapKey("x");
- expect(key.key).to.equal("x");
- expect(key.shift).to.be.false;
- expect(key.ctrl).to.be.false;
- expect(key.alt).to.be.false;
- expect(key.meta).to.be.false;
+ expect(key.key).toEqual("x");
+ expect(key.shift).toBeFalsy;
+ expect(key.ctrl).toBeFalsy;
+ expect(key.alt).toBeFalsy;
+ expect(key.meta).toBeFalsy;
});
it("return for Shift+X", () => {
const key = Key.fromMapKey("X");
- expect(key.key).to.equal("X");
- expect(key.shift).to.be.true;
- expect(key.ctrl).to.be.false;
- expect(key.alt).to.be.false;
- expect(key.meta).to.be.false;
+ expect(key.key).toEqual("X");
+ expect(key.shift).toBeTruthy;
+ expect(key.ctrl).toBeFalsy;
+ expect(key.alt).toBeFalsy;
+ expect(key.meta).toBeFalsy;
});
it("return for Ctrl+X", () => {
const key = Key.fromMapKey("<C-X>");
- expect(key.key).to.equal("x");
- expect(key.shift).to.be.false;
- expect(key.ctrl).to.be.true;
- expect(key.alt).to.be.false;
- expect(key.meta).to.be.false;
+ expect(key.key).toEqual("x");
+ expect(key.shift).toBeFalsy;
+ expect(key.ctrl).toBeTruthy;
+ expect(key.alt).toBeFalsy;
+ expect(key.meta).toBeFalsy;
});
it("returns for Ctrl+Meta+X", () => {
const key = Key.fromMapKey("<C-M-X>");
- expect(key.key).to.equal("x");
- expect(key.shift).to.be.false;
- expect(key.ctrl).to.be.true;
- expect(key.alt).to.be.false;
- expect(key.meta).to.be.true;
+ expect(key.key).toEqual("x");
+ expect(key.shift).toBeFalsy;
+ expect(key.ctrl).toBeTruthy;
+ expect(key.alt).toBeFalsy;
+ expect(key.meta).toBeTruthy;
});
it("returns for Ctrl+Shift+x", () => {
const key = Key.fromMapKey("<C-S-x>");
- expect(key.key).to.equal("X");
- expect(key.shift).to.be.true;
- expect(key.ctrl).to.be.true;
- expect(key.alt).to.be.false;
- expect(key.meta).to.be.false;
+ expect(key.key).toEqual("X");
+ expect(key.shift).toBeTruthy;
+ expect(key.ctrl).toBeTruthy;
+ expect(key.alt).toBeFalsy;
+ expect(key.meta).toBeFalsy;
});
it("returns for Shift+Esc", () => {
const key = Key.fromMapKey("<S-Esc>");
- expect(key.key).to.equal("Esc");
- expect(key.shift).to.be.true;
- expect(key.ctrl).to.be.false;
- expect(key.alt).to.be.false;
- expect(key.meta).to.be.false;
+ expect(key.key).toEqual("Esc");
+ expect(key.shift).toBeTruthy;
+ expect(key.ctrl).toBeFalsy;
+ expect(key.alt).toBeFalsy;
+ expect(key.meta).toBeFalsy;
});
it("returns for Ctrl+Esc", () => {
const key = Key.fromMapKey("<C-Esc>");
- expect(key.key).to.equal("Esc");
- expect(key.shift).to.be.false;
- expect(key.ctrl).to.be.true;
- expect(key.alt).to.be.false;
- expect(key.meta).to.be.false;
+ expect(key.key).toEqual("Esc");
+ expect(key.shift).toBeFalsy;
+ expect(key.ctrl).toBeTruthy;
+ expect(key.alt).toBeFalsy;
+ expect(key.meta).toBeFalsy;
});
it("returns for Ctrl+Esc", () => {
const key = Key.fromMapKey("<C-Space>");
- expect(key.key).to.equal("Space");
- expect(key.shift).to.be.false;
- expect(key.ctrl).to.be.true;
- expect(key.alt).to.be.false;
- expect(key.meta).to.be.false;
+ expect(key.key).toEqual("Space");
+ expect(key.shift).toBeFalsy;
+ expect(key.ctrl).toBeTruthy;
+ expect(key.alt).toBeFalsy;
+ expect(key.meta).toBeFalsy;
});
});
describe("idDigit", () => {
it("returns true if the key is a digit", () => {
- expect(new Key({ key: "0" }).isDigit()).to.be.true;
- expect(new Key({ key: "9" }).isDigit()).to.be.true;
- expect(new Key({ key: "9", alt: true }).isDigit()).to.be.false;
+ expect(new Key({ key: "0" }).isDigit()).toBeTruthy;
+ expect(new Key({ key: "9" }).isDigit()).toBeTruthy;
+ expect(new Key({ key: "9", alt: true }).isDigit()).toBeFalsy;
- expect(new Key({ key: "a" }).isDigit()).to.be.false;
- expect(new Key({ key: "0" }).isDigit()).to.be.false;
+ expect(new Key({ key: "a" }).isDigit()).toBeFalsy;
+ expect(new Key({ key: "0" }).isDigit()).toBeFalsy;
});
});
@@ -105,7 +104,7 @@ describe("Key", () => {
meta: false,
})
)
- ).to.be.true;
+ ).toBeTruthy;
expect(
new Key({
@@ -123,7 +122,7 @@ describe("Key", () => {
meta: false,
})
)
- ).to.be.false;
+ ).toBeFalsy;
});
});
});
diff --git a/test/shared/settings/Keymaps.test.ts b/test/shared/settings/Keymaps.test.ts
index 264684d..850e327 100644
--- a/test/shared/settings/Keymaps.test.ts
+++ b/test/shared/settings/Keymaps.test.ts
@@ -1,11 +1,10 @@
import Keymaps from "../../../src/shared/settings/Keymaps";
-import { expect } from "chai";
describe("Keymaps", () => {
describe("#valueOf", () => {
it("returns empty object by empty settings", () => {
const keymaps = Keymaps.fromJSON({}).toJSON();
- expect(keymaps).to.be.empty;
+ expect(keymaps).toEqual({});
});
it("returns keymaps by valid settings", () => {
@@ -14,11 +13,11 @@ describe("Keymaps", () => {
j: { type: "scroll.vertically", count: 1 },
}).toJSON();
- expect(keymaps["k"]).to.deep.equal({
+ expect(keymaps["k"]).toEqual({
type: "scroll.vertically",
count: -1,
});
- expect(keymaps["j"]).to.deep.equal({
+ expect(keymaps["j"]).toEqual({
type: "scroll.vertically",
count: 1,
});
@@ -29,7 +28,7 @@ describe("Keymaps", () => {
Keymaps.fromJSON({
k: { type: "invalid.operation" },
})
- ).to.throw(TypeError);
+ ).toThrow(TypeError);
});
});
@@ -48,7 +47,7 @@ describe("Keymaps", () => {
const entries = keymaps
.entries()
.sort(([name1], [name2]) => name1.localeCompare(name2));
- expect(entries).deep.equals([
+ expect(entries).toEqual([
["j", { type: "scroll.vertically", count: 1 }],
["k", { type: "scroll.vertically", count: -1 }],
["n", { type: "find.next" }],
@@ -70,7 +69,7 @@ describe("Keymaps", () => {
const entries = keymaps
.entries()
.sort(([name1], [name2]) => name1.localeCompare(name2));
- expect(entries).deep.equals([
+ expect(entries).toEqual([
["j", { type: "find.prev" }],
["k", { type: "scroll.vertically", count: -1 }],
["n", { type: "find.next" }],
diff --git a/test/shared/settings/Properties.test.ts b/test/shared/settings/Properties.test.ts
index 647cb1c..1161b48 100644
--- a/test/shared/settings/Properties.test.ts
+++ b/test/shared/settings/Properties.test.ts
@@ -1,12 +1,11 @@
import Properties from "../../../src/shared/settings/Properties";
-import { expect } from "chai";
import ColorScheme from "../../../src/shared/ColorScheme";
describe("Properties", () => {
describe("#propertiesValueOf", () => {
it("returns with default properties by empty settings", () => {
const props = Properties.fromJSON({});
- expect(props).to.deep.equal({
+ expect(props).toEqual({
hintchars: "abcdefghijklmnopqrstuvwxyz",
smoothscroll: false,
complete: "sbh",
@@ -22,7 +21,7 @@ describe("Properties", () => {
colorscheme: ColorScheme.System,
});
- expect(props).to.deep.equal({
+ expect(props).toEqual({
hintchars: "abcdefgh",
smoothscroll: false,
complete: "sbh",
diff --git a/test/shared/settings/Search.test.ts b/test/shared/settings/Search.test.ts
index 1feb14b..5d2f8d5 100644
--- a/test/shared/settings/Search.test.ts
+++ b/test/shared/settings/Search.test.ts
@@ -1,5 +1,4 @@
import Search from "../../../src/shared/settings/Search";
-import { expect } from "chai";
describe("Search", () => {
it("returns search settings by valid settings", () => {
@@ -11,12 +10,12 @@ describe("Search", () => {
},
});
- expect(search.defaultEngine).to.equal("google");
- expect(search.engines).to.deep.equals({
+ expect(search.defaultEngine).toEqual("google");
+ expect(search.engines).toEqual({
google: "https://google.com/search?q={}",
yahoo: "https://search.yahoo.com/search?p={}",
});
- expect(search.toJSON()).to.deep.equal({
+ expect(search.toJSON()).toEqual({
default: "google",
engines: {
google: "https://google.com/search?q={}",
@@ -34,7 +33,7 @@ describe("Search", () => {
yahoo: "https://search.yahoo.com/search?p={}",
},
})
- ).to.throw(TypeError);
+ ).toThrow(TypeError);
expect(() =>
Search.fromJSON({
default: "g o o g l e",
@@ -42,7 +41,7 @@ describe("Search", () => {
"g o o g l e": "https://google.com/search?q={}",
},
})
- ).to.throw(TypeError);
+ ).toThrow(TypeError);
expect(() =>
Search.fromJSON({
default: "google",
@@ -50,7 +49,7 @@ describe("Search", () => {
google: "https://google.com/search",
},
})
- ).to.throw(TypeError);
+ ).toThrow(TypeError);
expect(() =>
Search.fromJSON({
default: "google",
@@ -58,6 +57,6 @@ describe("Search", () => {
google: "https://google.com/search?q={}&r={}",
},
})
- ).to.throw(TypeError);
+ ).toThrow(TypeError);
});
});
diff --git a/test/shared/settings/Settings.test.ts b/test/shared/settings/Settings.test.ts
index 951c9cd..49a5d0b 100644
--- a/test/shared/settings/Settings.test.ts
+++ b/test/shared/settings/Settings.test.ts
@@ -1,5 +1,4 @@
import Settings from "../../../src/shared/settings/Settings";
-import { expect } from "chai";
describe("Settings", () => {
describe("#valueOf", () => {
@@ -21,7 +20,7 @@ describe("Settings", () => {
search: x.search.toJSON(),
properties: x.properties.toJSON(),
blacklist: x.blacklist.toJSON(),
- }).to.deep.equal({
+ }).toEqual({
keymaps: {},
search: {
default: "google",
@@ -41,15 +40,15 @@ describe("Settings", () => {
it("sets default settings", () => {
const value = Settings.fromJSON({});
- expect(value.keymaps.toJSON()).to.not.be.empty;
- expect(value.properties.toJSON()).to.not.be.empty;
- expect(value.search.defaultEngine).to.be.a("string");
- expect(value.search.engines).to.be.an("object");
- expect(value.blacklist.toJSON()).to.be.empty;
+ expect(value.keymaps.toJSON()).not.toEqual({});
+ expect(value.properties.toJSON()).not.toEqual({});
+ expect(typeof value.search.defaultEngine).toEqual("string");
+ expect(typeof value.search.engines).toEqual("object");
+ expect(value.blacklist.toJSON()).toHaveLength(0);
});
it("throws a TypeError with an unknown field", () => {
- expect(() => Settings.fromJSON({ name: "alice" })).to.throw(TypeError);
+ expect(() => Settings.fromJSON({ name: "alice" })).toThrow(TypeError);
});
});
});
diff --git a/test/shared/urls.test.ts b/test/shared/urls.test.ts
index f264ad9..ec618f6 100644
--- a/test/shared/urls.test.ts
+++ b/test/shared/urls.test.ts
@@ -1,5 +1,4 @@
import * as parsers from "../../src/shared/urls";
-import { expect } from "chai";
import Search from "../../src/shared/settings/Search";
describe("shared/commands/parsers", () => {
@@ -13,55 +12,55 @@ describe("shared/commands/parsers", () => {
});
it("convertes search url", () => {
- expect(parsers.searchUrl("google.com", config)).to.equal(
+ expect(parsers.searchUrl("google.com", config)).toEqual(
"http://google.com"
);
- expect(parsers.searchUrl("google apple", config)).to.equal(
+ expect(parsers.searchUrl("google apple", config)).toEqual(
"https://google.com/search?q=apple"
);
- expect(parsers.searchUrl("yahoo apple", config)).to.equal(
+ expect(parsers.searchUrl("yahoo apple", config)).toEqual(
"https://yahoo.com/search?q=apple"
);
- expect(parsers.searchUrl("google apple banana", config)).to.equal(
+ expect(parsers.searchUrl("google apple banana", config)).toEqual(
"https://google.com/search?q=apple%20banana"
);
- expect(parsers.searchUrl("yahoo C++CLI", config)).to.equal(
+ expect(parsers.searchUrl("yahoo C++CLI", config)).toEqual(
"https://yahoo.com/search?q=C%2B%2BCLI"
);
});
it("user default search engine", () => {
- expect(parsers.searchUrl("apple banana", config)).to.equal(
+ expect(parsers.searchUrl("apple banana", config)).toEqual(
"https://google.com/search?q=apple%20banana"
);
});
it("searches with a word containing a colon", () => {
- expect(parsers.searchUrl("foo:", config)).to.equal(
+ expect(parsers.searchUrl("foo:", config)).toEqual(
"https://google.com/search?q=foo%3A"
);
- expect(parsers.searchUrl("std::vector", config)).to.equal(
+ expect(parsers.searchUrl("std::vector", config)).toEqual(
"https://google.com/search?q=std%3A%3Avector"
);
});
it("localhost urls", () => {
- expect(parsers.searchUrl("localhost", config)).to.equal(
+ expect(parsers.searchUrl("localhost", config)).toEqual(
"http://localhost"
);
- expect(parsers.searchUrl("http://localhost", config)).to.equal(
+ expect(parsers.searchUrl("http://localhost", config)).toEqual(
"http://localhost/"
);
- expect(parsers.searchUrl("localhost:8080", config)).to.equal(
+ expect(parsers.searchUrl("localhost:8080", config)).toEqual(
"http://localhost:8080"
);
- expect(parsers.searchUrl("localhost:80nan", config)).to.equal(
+ expect(parsers.searchUrl("localhost:80nan", config)).toEqual(
"https://google.com/search?q=localhost%3A80nan"
);
- expect(parsers.searchUrl("localhost 8080", config)).to.equal(
+ expect(parsers.searchUrl("localhost 8080", config)).toEqual(
"https://google.com/search?q=localhost%208080"
);
- expect(parsers.searchUrl("localhost:80/build", config)).to.equal(
+ expect(parsers.searchUrl("localhost:80/build", config)).toEqual(
"http://localhost:80/build"
);
});
@@ -69,10 +68,10 @@ describe("shared/commands/parsers", () => {
describe("#normalizeUrl", () => {
it("normalize urls", () => {
- expect(parsers.normalizeUrl("https://google.com/")).to.equal(
+ expect(parsers.normalizeUrl("https://google.com/")).toEqual(
"https://google.com/"
);
- expect(parsers.normalizeUrl("google.com")).to.equal("http://google.com");
+ expect(parsers.normalizeUrl("google.com")).toEqual("http://google.com");
});
});
});