aboutsummaryrefslogtreecommitdiff
path: root/test/shared/settings
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-05-02 17:25:56 +0900
committerGitHub <noreply@github.com>2020-05-02 17:25:56 +0900
commit5df0537bcf65a341e79852b1b30379c73318529c (patch)
treeaee5efe52412855f620cb514a13a2c14373f27b7 /test/shared/settings
parent685f2b7b69218b06b5bb676069e35f79c5048c9b (diff)
parent75abd90ecb8201ad845b266f96220d8adfe19b2d (diff)
Merge pull request #749 from ueokande/qa-0.28
QA 0.28
Diffstat (limited to 'test/shared/settings')
-rw-r--r--test/shared/settings/Blacklist.test.ts210
-rw-r--r--test/shared/settings/Key.test.ts120
-rw-r--r--test/shared/settings/Keymaps.test.ts81
-rw-r--r--test/shared/settings/Properties.test.ts21
-rw-r--r--test/shared/settings/Search.test.ts90
-rw-r--r--test/shared/settings/Settings.test.ts40
6 files changed, 323 insertions, 239 deletions
diff --git a/test/shared/settings/Blacklist.test.ts b/test/shared/settings/Blacklist.test.ts
index bcddf18..1ccb32a 100644
--- a/test/shared/settings/Blacklist.test.ts
+++ b/test/shared/settings/Blacklist.test.ts
@@ -1,140 +1,178 @@
-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');
+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;
});
- it('parses partial blacklist item', () => {
- const item = BlacklistItem.fromJSON({ url: 'example.com', keys: ['j', 'k']});
- expect(item.pattern).to.equal('example.com');
+ it("parses partial blacklist item", () => {
+ const item = BlacklistItem.fromJSON({
+ 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.keys).to.deep.equal(["j", "k"]);
});
});
- describe('#matches', () => {
+ describe("#matches", () => {
it('matches by "*"', () => {
- const item = BlacklistItem.fromJSON('*');
- expect(item.matches(new URL('https://github.com/abc'))).to.be.true;
+ const item = BlacklistItem.fromJSON("*");
+ expect(item.matches(new URL("https://github.com/abc"))).to.be.true;
});
- 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;
+ 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;
});
- it('matches by hostname with wildcard', () => {
- const item = BlacklistItem.fromJSON('*.github.com');
+ 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"))).to.be.false;
+ expect(item.matches(new URL("https://gist.github.com"))).to.be.true;
});
- it('matches by path', () => {
- const item = BlacklistItem.fromJSON('github.com/abc');
+ 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"))).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;
});
- it('matches by path with wildcard', () => {
- const item = BlacklistItem.fromJSON('github.com/abc*');
+ 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"))).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;
});
- it('matches address and port', () => {
- const item = BlacklistItem.fromJSON('127.0.0.1:8888');
+ 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/"))).to.be.true;
+ expect(item.matches(new URL("http://127.0.0.1:8888/hello"))).to.be.true;
});
- it('matches with partial blacklist', () => {
- const item = BlacklistItem.fromJSON({ url: 'google.com', keys: ['j', 'k'] });
+ it("matches with partial blacklist", () => {
+ const item = BlacklistItem.fromJSON({
+ url: "google.com",
+ 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"))).to.be.true;
+ expect(item.matches(new URL("https://yahoo.com"))).to.be.false;
+ });
});
- describe('#includesPartialKeys', () => {
- it('matches with partial keys', () => {
- const item = BlacklistItem.fromJSON({url: 'google.com', keys: ['j', 'k', '<C-U>']});
-
- expect(item.includeKey(new URL('http://google.com/maps'), Key.fromMapKey('j'))).to.be.true;
- expect(item.includeKey(new URL('http://google.com/maps'), Key.fromMapKey('<C-U>'))).to.be.true;
- expect(item.includeKey(new URL('http://google.com/maps'), Key.fromMapKey('z'))).to.be.false;
- expect(item.includeKey(new URL('http://google.com/maps'), Key.fromMapKey('u'))).to.be.false;
- expect(item.includeKey(new URL('http://maps.google.com/'), Key.fromMapKey('j'))).to.be.false;
- })
+ describe("#includesPartialKeys", () => {
+ it("matches with partial keys", () => {
+ const item = BlacklistItem.fromJSON({
+ url: "google.com",
+ keys: ["j", "k", "<C-U>"],
+ });
+
+ expect(
+ item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("j"))
+ ).to.be.true;
+ expect(
+ item.includeKey(
+ new URL("http://google.com/maps"),
+ Key.fromMapKey("<C-U>")
+ )
+ ).to.be.true;
+ expect(
+ item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("z"))
+ ).to.be.false;
+ expect(
+ item.includeKey(new URL("http://google.com/maps"), Key.fromMapKey("u"))
+ ).to.be.false;
+ expect(
+ item.includeKey(new URL("http://maps.google.com/"), Key.fromMapKey("j"))
+ ).to.be.false;
+ });
});
});
-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',
- ]);
+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"]);
});
- it('parses mixed blacklist', () => {
+ it("parses mixed blacklist", () => {
const blacklist = Blacklist.fromJSON([
- { url: 'example.com', keys: ['j', 'k']},
- 'example.org',
+ { url: "example.com", keys: ["j", "k"] },
+ "example.org",
]);
expect(blacklist.toJSON()).to.deep.equals([
- { url: 'example.com', keys: ['j', 'k']},
- 'example.org',
+ { url: "example.com", keys: ["j", "k"] },
+ "example.org",
]);
});
- it('parses empty blacklist', () => {
+ it("parses empty blacklist", () => {
const blacklist = Blacklist.fromJSON([]);
expect(blacklist.toJSON()).to.deep.equals([]);
});
});
- describe('#includesEntireBlacklist', () => {
- 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;
- expect(blacklist.includesEntireBlacklist(new URL('https://github.com'))).to.be.false;
- expect(blacklist.includesEntireBlacklist(new URL('https://gist.github.com'))).to.be.true;
+ describe("#includesEntireBlacklist", () => {
+ 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;
+ expect(blacklist.includesEntireBlacklist(new URL("https://github.com")))
+ .to.be.false;
+ expect(
+ blacklist.includesEntireBlacklist(new URL("https://gist.github.com"))
+ ).to.be.true;
});
- it('does not matches with partial blacklist', () => {
- const blacklist = Blacklist.fromJSON(['google.com', { 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;
+ it("does not matches with partial blacklist", () => {
+ const blacklist = Blacklist.fromJSON([
+ "google.com",
+ { 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;
});
});
- describe('#includesKeys', () => {
- it('matches with entire blacklist or keys in the partial blacklist', () => {
+ describe("#includesKeys", () => {
+ it("matches with entire blacklist or keys in the partial blacklist", () => {
const blacklist = Blacklist.fromJSON([
- 'google.com',
- { url: 'github.com', keys: ['j', 'k'] },
+ "google.com",
+ { url: "github.com", keys: ["j", "k"] },
]);
- expect(blacklist.includeKey(new URL('https://google.com'), Key.fromMapKey('j'))).to.be.false;
- expect(blacklist.includeKey(new URL('https://github.com'), Key.fromMapKey('j'))).to.be.true;
- expect(blacklist.includeKey(new URL('https://github.com'), Key.fromMapKey('a'))).to.be.false;
+ expect(
+ blacklist.includeKey(new URL("https://google.com"), Key.fromMapKey("j"))
+ ).to.be.false;
+ expect(
+ blacklist.includeKey(new URL("https://github.com"), Key.fromMapKey("j"))
+ ).to.be.true;
+ expect(
+ blacklist.includeKey(new URL("https://github.com"), Key.fromMapKey("a"))
+ ).to.be.false;
});
});
});
diff --git a/test/shared/settings/Key.test.ts b/test/shared/settings/Key.test.ts
index b8538f8..47af1d9 100644
--- a/test/shared/settings/Key.test.ts
+++ b/test/shared/settings/Key.test.ts
@@ -1,74 +1,74 @@
-import { expect } from 'chai'
-import Key from '../../../src/shared/settings/Key';
+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');
+ 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;
});
- it('return for Shift+X', () => {
- const key = Key.fromMapKey('X');
- expect(key.key).to.equal('X');
+ 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;
});
- it('return for Ctrl+X', () => {
- const key = Key.fromMapKey('<C-X>');
- expect(key.key).to.equal('x');
+ 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;
});
- it('returns for Ctrl+Meta+X', () => {
- const key = Key.fromMapKey('<C-M-X>');
- expect(key.key).to.equal('x');
+ 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;
});
- it('returns for Ctrl+Shift+x', () => {
- const key = Key.fromMapKey('<C-S-x>');
- expect(key.key).to.equal('X');
+ 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;
});
- it('returns for Shift+Esc', () => {
- const key = Key.fromMapKey('<S-Esc>');
- expect(key.key).to.equal('Esc');
+ 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;
});
- it('returns for Ctrl+Esc', () => {
- const key = Key.fromMapKey('<C-Esc>');
- expect(key.key).to.equal('Esc');
+ 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;
});
- it('returns for Ctrl+Esc', () => {
- const key = Key.fromMapKey('<C-Space>');
- expect(key.key).to.equal('Space');
+ 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;
@@ -76,30 +76,54 @@ describe("Key", () => {
});
});
- 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;
+ 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: 'a' }).isDigit()).to.be.false;
- expect(new Key({ key: '0' }).isDigit()).to.be.false;
- })
+ expect(new Key({ key: "a" }).isDigit()).to.be.false;
+ expect(new Key({ key: "0" }).isDigit()).to.be.false;
+ });
});
- describe('equals', () => {
- it('returns true if the keys are equivalent', () => {
- expect(new Key({
- key: 'x', shift: false, ctrl: true, alt: false, meta: false,
- }).equals(new Key({
- key: 'x', shift: false, ctrl: true, alt: false, meta: false,
- }))).to.be.true;
+ describe("equals", () => {
+ it("returns true if the keys are equivalent", () => {
+ expect(
+ new Key({
+ key: "x",
+ shift: false,
+ ctrl: true,
+ alt: false,
+ meta: false,
+ }).equals(
+ new Key({
+ key: "x",
+ shift: false,
+ ctrl: true,
+ alt: false,
+ meta: false,
+ })
+ )
+ ).to.be.true;
- expect(new Key({
- key: 'x', shift: false, ctrl: false, alt: false, meta: false,
- }).equals(new Key({
- key: 'X', shift: true, ctrl: false, alt: false, meta: false,
- }))).to.be.false;
- })
+ expect(
+ new Key({
+ key: "x",
+ shift: false,
+ ctrl: false,
+ alt: false,
+ meta: false,
+ }).equals(
+ new Key({
+ key: "X",
+ shift: true,
+ ctrl: false,
+ alt: false,
+ meta: false,
+ })
+ )
+ ).to.be.false;
+ });
});
});
diff --git a/test/shared/settings/Keymaps.test.ts b/test/shared/settings/Keymaps.test.ts
index dcea6e4..264684d 100644
--- a/test/shared/settings/Keymaps.test.ts
+++ b/test/shared/settings/Keymaps.test.ts
@@ -1,65 +1,80 @@
-import Keymaps from '../../../src/shared/settings/Keymaps';
-import { expect } from 'chai';
+import Keymaps from "../../../src/shared/settings/Keymaps";
+import { expect } from "chai";
-describe('Keymaps', () => {
- describe('#valueOf', () => {
- it('returns empty object by empty settings', () => {
+describe("Keymaps", () => {
+ describe("#valueOf", () => {
+ it("returns empty object by empty settings", () => {
const keymaps = Keymaps.fromJSON({}).toJSON();
expect(keymaps).to.be.empty;
});
- it('returns keymaps by valid settings', () => {
+ it("returns keymaps by valid settings", () => {
const keymaps = Keymaps.fromJSON({
k: { type: "scroll.vertically", count: -1 },
j: { type: "scroll.vertically", count: 1 },
}).toJSON();
- expect(keymaps['k']).to.deep.equal({ type: "scroll.vertically", count: -1 });
- expect(keymaps['j']).to.deep.equal({ type: "scroll.vertically", count: 1 });
+ expect(keymaps["k"]).to.deep.equal({
+ type: "scroll.vertically",
+ count: -1,
+ });
+ expect(keymaps["j"]).to.deep.equal({
+ type: "scroll.vertically",
+ count: 1,
+ });
});
- it('throws a TypeError by invalid settings', () => {
- expect(() => Keymaps.fromJSON({
- k: { type: "invalid.operation" },
- })).to.throw(TypeError);
+ it("throws a TypeError by invalid settings", () => {
+ expect(() =>
+ Keymaps.fromJSON({
+ k: { type: "invalid.operation" },
+ })
+ ).to.throw(TypeError);
});
});
- describe('#combine', () => {
- it('returns combined keymaps', () => {
+ describe("#combine", () => {
+ it("returns combined keymaps", () => {
const keymaps = Keymaps.fromJSON({
k: { type: "scroll.vertically", count: -1 },
j: { type: "scroll.vertically", count: 1 },
- }).combine(Keymaps.fromJSON({
- n: { type: "find.next" },
- N: { type: "find.prev" },
- }));
+ }).combine(
+ Keymaps.fromJSON({
+ n: { type: "find.next" },
+ N: { type: "find.prev" },
+ })
+ );
- const entries = keymaps.entries().sort(([name1], [name2]) => name1.localeCompare(name2));
+ const entries = keymaps
+ .entries()
+ .sort(([name1], [name2]) => name1.localeCompare(name2));
expect(entries).deep.equals([
- ['j', { type: "scroll.vertically", count: 1 }],
- ['k', { type: "scroll.vertically", count: -1 }],
- ['n', { type: "find.next" }],
- ['N', { type: "find.prev" }],
+ ["j", { type: "scroll.vertically", count: 1 }],
+ ["k", { type: "scroll.vertically", count: -1 }],
+ ["n", { type: "find.next" }],
+ ["N", { type: "find.prev" }],
]);
});
- it('overrides current keymaps', () => {
+ it("overrides current keymaps", () => {
const keymaps = Keymaps.fromJSON({
k: { type: "scroll.vertically", count: -1 },
j: { type: "scroll.vertically", count: 1 },
- }).combine(Keymaps.fromJSON({
- n: { type: "find.next" },
- j: { type: "find.prev" },
- }));
+ }).combine(
+ Keymaps.fromJSON({
+ n: { type: "find.next" },
+ j: { type: "find.prev" },
+ })
+ );
- const entries = keymaps.entries().sort(([name1], [name2]) => name1.localeCompare(name2));
+ const entries = keymaps
+ .entries()
+ .sort(([name1], [name2]) => name1.localeCompare(name2));
expect(entries).deep.equals([
- ['j', { type: "find.prev" }],
- ['k', { type: "scroll.vertically", count: -1 }],
- ['n', { type: "find.next" }],
+ ["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 4639839..6007e84 100644
--- a/test/shared/settings/Properties.test.ts
+++ b/test/shared/settings/Properties.test.ts
@@ -1,30 +1,29 @@
-import Properties from '../../../src/shared/settings/Properties';
-import { expect } from 'chai';
+import Properties from "../../../src/shared/settings/Properties";
+import { expect } from "chai";
-describe('Properties', () => {
- describe('#propertiesValueOf', () => {
- it('returns with default properties by empty settings', () => {
+describe("Properties", () => {
+ describe("#propertiesValueOf", () => {
+ it("returns with default properties by empty settings", () => {
const props = Properties.fromJSON({});
expect(props).to.deep.equal({
hintchars: "abcdefghijklmnopqrstuvwxyz",
smoothscroll: false,
- complete: "sbh"
- })
+ complete: "sbh",
+ });
});
- it('returns properties by valid settings', () => {
+ it("returns properties by valid settings", () => {
const props = Properties.fromJSON({
hintchars: "abcdefgh",
smoothscroll: false,
- complete: "sbh"
+ complete: "sbh",
});
expect(props).to.deep.equal({
hintchars: "abcdefgh",
smoothscroll: false,
- complete: "sbh"
+ complete: "sbh",
});
});
});
});
-
diff --git a/test/shared/settings/Search.test.ts b/test/shared/settings/Search.test.ts
index 8bd8d89..1feb14b 100644
--- a/test/shared/settings/Search.test.ts
+++ b/test/shared/settings/Search.test.ts
@@ -1,55 +1,63 @@
-import Search from '../../../src/shared/settings/Search';
-import { expect } from 'chai';
+import Search from "../../../src/shared/settings/Search";
+import { expect } from "chai";
-describe('Search', () => {
- it('returns search settings by valid settings', () => {
+describe("Search", () => {
+ it("returns search settings by valid settings", () => {
const search = Search.fromJSON({
- default: 'google',
+ default: "google",
engines: {
- 'google': 'https://google.com/search?q={}',
- 'yahoo': 'https://search.yahoo.com/search?p={}',
- }
+ google: "https://google.com/search?q={}",
+ yahoo: "https://search.yahoo.com/search?p={}",
+ },
});
- expect(search.defaultEngine).to.equal('google')
+ expect(search.defaultEngine).to.equal("google");
expect(search.engines).to.deep.equals({
- 'google': 'https://google.com/search?q={}',
- 'yahoo': 'https://search.yahoo.com/search?p={}',
+ google: "https://google.com/search?q={}",
+ yahoo: "https://search.yahoo.com/search?p={}",
});
expect(search.toJSON()).to.deep.equal({
- default: 'google',
+ default: "google",
engines: {
- 'google': 'https://google.com/search?q={}',
- 'yahoo': 'https://search.yahoo.com/search?p={}',
- }
+ google: "https://google.com/search?q={}",
+ yahoo: "https://search.yahoo.com/search?p={}",
+ },
});
});
- it('throws a TypeError by invalid settings', () => {
- expect(() => Search.fromJSON({
- default: 'wikipedia',
- engines: {
- 'google': 'https://google.com/search?q={}',
- 'yahoo': 'https://search.yahoo.com/search?p={}',
- }
- })).to.throw(TypeError);
- expect(() => Search.fromJSON({
- default: 'g o o g l e',
- engines: {
- 'g o o g l e': 'https://google.com/search?q={}',
- }
- })).to.throw(TypeError);
- expect(() => Search.fromJSON({
- default: 'google',
- engines: {
- 'google': 'https://google.com/search',
- }
- })).to.throw(TypeError);
- expect(() => Search.fromJSON({
- default: 'google',
- engines: {
- 'google': 'https://google.com/search?q={}&r={}',
- }
- })).to.throw(TypeError);
+ it("throws a TypeError by invalid settings", () => {
+ expect(() =>
+ Search.fromJSON({
+ default: "wikipedia",
+ engines: {
+ google: "https://google.com/search?q={}",
+ yahoo: "https://search.yahoo.com/search?p={}",
+ },
+ })
+ ).to.throw(TypeError);
+ expect(() =>
+ Search.fromJSON({
+ default: "g o o g l e",
+ engines: {
+ "g o o g l e": "https://google.com/search?q={}",
+ },
+ })
+ ).to.throw(TypeError);
+ expect(() =>
+ Search.fromJSON({
+ default: "google",
+ engines: {
+ google: "https://google.com/search",
+ },
+ })
+ ).to.throw(TypeError);
+ expect(() =>
+ Search.fromJSON({
+ default: "google",
+ engines: {
+ google: "https://google.com/search?q={}&r={}",
+ },
+ })
+ ).to.throw(TypeError);
});
});
diff --git a/test/shared/settings/Settings.test.ts b/test/shared/settings/Settings.test.ts
index 658132c..4ecfe77 100644
--- a/test/shared/settings/Settings.test.ts
+++ b/test/shared/settings/Settings.test.ts
@@ -1,19 +1,19 @@
-import Settings from '../../../src/shared/settings/Settings';
-import { expect } from 'chai';
+import Settings from "../../../src/shared/settings/Settings";
+import { expect } from "chai";
-describe('Settings', () => {
- describe('#valueOf', () => {
- it('returns settings by valid settings', () => {
+describe("Settings", () => {
+ describe("#valueOf", () => {
+ it("returns settings by valid settings", () => {
const x = Settings.fromJSON({
keymaps: {},
- "search": {
- "default": "google",
- "engines": {
- "google": "https://google.com/search?q={}",
- }
+ search: {
+ default: "google",
+ engines: {
+ google: "https://google.com/search?q={}",
+ },
},
- "properties": {},
- "blacklist": []
+ properties: {},
+ blacklist: [],
});
expect({
@@ -27,28 +27,28 @@ describe('Settings', () => {
default: "google",
engines: {
google: "https://google.com/search?q={}",
- }
+ },
},
properties: {
hintchars: "abcdefghijklmnopqrstuvwxyz",
smoothscroll: false,
- complete: "sbh"
+ complete: "sbh",
},
- blacklist: []
+ blacklist: [],
});
});
- it('sets default 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.search.defaultEngine).to.be.a("string");
+ expect(value.search.engines).to.be.an("object");
expect(value.blacklist.toJSON()).to.be.empty;
});
- it('throws a TypeError with an unknown field', () => {
- expect(() => Settings.fromJSON({ name: 'alice' })).to.throw(TypeError)
+ it("throws a TypeError with an unknown field", () => {
+ expect(() => Settings.fromJSON({ name: "alice" })).to.throw(TypeError);
});
});
});