aboutsummaryrefslogtreecommitdiff
path: root/test/shared
diff options
context:
space:
mode:
Diffstat (limited to 'test/shared')
-rw-r--r--test/shared/SettingData.test.ts40
-rw-r--r--test/shared/operations.test.ts4
-rw-r--r--test/shared/settings/Blacklist.test.ts50
-rw-r--r--test/shared/settings/Key.test.ts49
-rw-r--r--test/shared/settings/KeySequence.test.ts72
-rw-r--r--test/shared/settings/Keymaps.test.ts13
-rw-r--r--test/shared/settings/Properties.test.ts4
-rw-r--r--test/shared/settings/Search.test.ts15
-rw-r--r--test/shared/settings/Settings.test.ts4
-rw-r--r--test/shared/urls.test.ts16
10 files changed, 95 insertions, 172 deletions
diff --git a/test/shared/SettingData.test.ts b/test/shared/SettingData.test.ts
index 5de7770..0632176 100644
--- a/test/shared/SettingData.test.ts
+++ b/test/shared/SettingData.test.ts
@@ -9,12 +9,12 @@ describe('shared/SettingData', () => {
describe('FormKeymaps', () => {
describe('#valueOF to #toKeymaps', () => {
it('parses form keymaps and convert to operations', () => {
- let data = {
+ const data = {
'scroll.vertically?{"count":1}': 'j',
'scroll.home': '0',
};
- let keymaps = FormKeymaps.fromJSON(data).toKeymaps().toJSON();
+ const keymaps = FormKeymaps.fromJSON(data).toKeymaps().toJSON();
expect(keymaps).to.deep.equal({
'j': { type: 'scroll.vertically', count: 1 },
'0': { type: 'scroll.home' },
@@ -24,12 +24,12 @@ describe('shared/SettingData', () => {
describe('#fromKeymaps to #toJSON', () => {
it('create from a Keymaps and create a JSON object', () => {
- let keymaps: Keymaps = Keymaps.fromJSON({
+ const keymaps: Keymaps = Keymaps.fromJSON({
'j': { type: 'scroll.vertically', count: 1 },
'0': { type: 'scroll.home' },
});
- let form = FormKeymaps.fromKeymaps(keymaps).toJSON();
+ const form = FormKeymaps.fromKeymaps(keymaps).toJSON();
expect(form).to.deep.equal({
'scroll.vertically?{"count":1}': 'j',
'scroll.home': '0',
@@ -41,7 +41,7 @@ describe('shared/SettingData', () => {
describe('JSONSettings', () => {
describe('#valueOf to #toSettings', () => {
it('parse object and create a Settings', () => {
- let o = `{
+ const o = `{
"keymaps": {},
"search": {
"default": "google",
@@ -57,14 +57,14 @@ describe('shared/SettingData', () => {
"blacklist": []
}`;
- let settings = JSONTextSettings.fromText(o).toSettings();
+ const settings = JSONTextSettings.fromText(o).toSettings();
expect(settings.toJSON()).to.deep.equal(JSON.parse(o));
});
});
describe('#fromSettings to #toJSON', () => {
it('create from a Settings and create a JSON string', () => {
- let o = Settings.fromJSON({
+ const o = Settings.fromJSON({
keymaps: {},
search: {
default: "google",
@@ -80,7 +80,7 @@ describe('shared/SettingData', () => {
blacklist: [],
});
- let json = JSONTextSettings.fromSettings(o).toJSONText();
+ const json = JSONTextSettings.fromSettings(o).toJSONText();
expect(JSON.parse(json)).to.deep.equal(o.toJSON());
});
});
@@ -89,7 +89,7 @@ describe('shared/SettingData', () => {
describe('FormSettings', () => {
describe('#valueOf to #toSettings', () => {
it('parse object and create a Settings', () => {
- let data = {
+ const data = {
keymaps: {
'scroll.vertically?{"count":1}': 'j',
'scroll.home': '0',
@@ -108,7 +108,7 @@ describe('shared/SettingData', () => {
blacklist: []
};
- let settings = FormSettings.fromJSON(data).toSettings();
+ const settings = FormSettings.fromJSON(data).toSettings();
expect(settings.toJSON()).to.deep.equal({
keymaps: {
'j': { type: 'scroll.vertically', count: 1 },
@@ -132,7 +132,7 @@ describe('shared/SettingData', () => {
describe('#fromSettings to #toJSON', () => {
it('create from a Settings and create a JSON string', () => {
- let data: Settings = Settings.fromJSON({
+ const data: Settings = Settings.fromJSON({
keymaps: {
'j': { type: 'scroll.vertically', count: 1 },
'0': { type: 'scroll.home' },
@@ -151,7 +151,7 @@ describe('shared/SettingData', () => {
blacklist: [],
});
- let json = FormSettings.fromSettings(data).toJSON();
+ const json = FormSettings.fromSettings(data).toJSON();
expect(json).to.deep.equal({
keymaps: {
'scroll.vertically?{"count":1}': 'j',
@@ -177,7 +177,7 @@ describe('shared/SettingData', () => {
describe('SettingData', () => {
describe('#valueOf to #toJSON', () => {
it('parse object from json source', () => {
- let data = {
+ const data = {
source: 'json',
json: `{
"keymaps": {},
@@ -196,13 +196,13 @@ describe('shared/SettingData', () => {
}`,
};
- let j = SettingData.fromJSON(data).toJSON();
+ const j = SettingData.fromJSON(data).toJSON();
expect(j.source).to.equal('json');
expect(j.json).to.be.a('string');
});
it('parse object from form source', () => {
- let data = {
+ const data = {
source: 'form',
form: {
keymaps: {},
@@ -221,7 +221,7 @@ describe('shared/SettingData', () => {
},
};
- let j = SettingData.fromJSON(data).toJSON();
+ const j = SettingData.fromJSON(data).toJSON();
expect(j.source).to.equal('form');
expect(j.form).to.deep.equal({
keymaps: {},
@@ -243,7 +243,7 @@ describe('shared/SettingData', () => {
describe('#toSettings', () => {
it('parse object from json source', () => {
- let data = {
+ const data = {
source: 'json',
json: `{
"keymaps": {},
@@ -262,12 +262,12 @@ describe('shared/SettingData', () => {
}`,
};
- let settings = SettingData.fromJSON(data).toSettings();
+ const settings = SettingData.fromJSON(data).toSettings();
expect(settings.search.defaultEngine).to.equal('google');
});
it('parse object from form source', () => {
- let data = {
+ const data = {
source: 'form',
form: {
keymaps: {},
@@ -286,7 +286,7 @@ describe('shared/SettingData', () => {
},
};
- let settings = SettingData.fromJSON(data).toSettings();
+ const settings = SettingData.fromJSON(data).toSettings();
expect(settings.search.defaultEngine).to.equal('yahoo');
});
});
diff --git a/test/shared/operations.test.ts b/test/shared/operations.test.ts
index 42a3eed..fbb6193 100644
--- a/test/shared/operations.test.ts
+++ b/test/shared/operations.test.ts
@@ -3,7 +3,7 @@ import * as operations from 'shared/operations';
describe('operations', () => {
describe('#valueOf', () => {
it('returns an Operation', () => {
- let op: operations.Operation = operations.valueOf({
+ const op: operations.Operation = operations.valueOf({
type: operations.SCROLL_VERTICALLY,
count: 10,
});
@@ -18,7 +18,7 @@ describe('operations', () => {
});
it('fills default valus of optional parameter', () => {
- let op: operations.Operation = operations.valueOf({
+ const op: operations.Operation = operations.valueOf({
type: operations.COMMAND_SHOW_OPEN,
});
diff --git a/test/shared/settings/Blacklist.test.ts b/test/shared/settings/Blacklist.test.ts
index 133112c..dfd036e 100644
--- a/test/shared/settings/Blacklist.test.ts
+++ b/test/shared/settings/Blacklist.test.ts
@@ -5,37 +5,27 @@ import Key from '../../../src/shared/settings/Key';
describe('BlacklistItem', () => {
describe('#fromJSON', () => {
it('parses string pattern', () => {
- let item = BlacklistItem.fromJSON('example.com');
+ const item = BlacklistItem.fromJSON('example.com');
expect(item.pattern).to.equal('example.com');
expect(item.partial).to.be.false;
});
it('parses partial blacklist item', () => {
- let item = BlacklistItem.fromJSON({ url: 'example.com', keys: ['j', 'k']});
+ 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']);
});
-
- it('throws a TypeError', () => {
- expect(() => BlacklistItem.fromJSON(null)).to.throw(TypeError);
- expect(() => BlacklistItem.fromJSON(100)).to.throw(TypeError);
- expect(() => BlacklistItem.fromJSON({})).to.throw(TypeError);
- expect(() => BlacklistItem.fromJSON({url: 'google.com'})).to.throw(TypeError);
- expect(() => BlacklistItem.fromJSON({keys: ['a']})).to.throw(TypeError);
- expect(() => BlacklistItem.fromJSON({url: 'google.com', keys: 10})).to.throw(TypeError);
- expect(() => BlacklistItem.fromJSON({url: 'google.com', keys: ['a', 'b', 3]})).to.throw(TypeError);
- });
});
describe('#matches', () => {
it('matches by "*"', () => {
- let item = BlacklistItem.fromJSON('*');
+ const item = BlacklistItem.fromJSON('*');
expect(item.matches(new URL('https://github.com/abc'))).to.be.true;
});
it('matches by hostname', () => {
- let item = BlacklistItem.fromJSON('github.com');
+ 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;
@@ -44,14 +34,14 @@ describe('BlacklistItem', () => {
});
it('matches by hostname with wildcard', () => {
- let item = BlacklistItem.fromJSON('*.github.com');
+ 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;
});
it('matches by path', () => {
- let item = BlacklistItem.fromJSON('github.com/abc');
+ 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;
@@ -59,7 +49,7 @@ describe('BlacklistItem', () => {
});
it('matches by path with wildcard', () => {
- let item = BlacklistItem.fromJSON('github.com/abc*');
+ 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;
@@ -67,14 +57,14 @@ describe('BlacklistItem', () => {
});
it('matches address and port', () => {
- let item = BlacklistItem.fromJSON('127.0.0.1:8888');
+ 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;
});
it('matches with partial blacklist', () => {
- let item = BlacklistItem.fromJSON({ url: 'google.com', keys: ['j', 'k'] });
+ 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;
@@ -83,7 +73,7 @@ describe('BlacklistItem', () => {
describe('#includesPartialKeys', () => {
it('matches with partial keys', () => {
- let item = BlacklistItem.fromJSON({url: 'google.com', keys: ['j', 'k', '<C-U>']});
+ 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;
@@ -97,14 +87,14 @@ describe('BlacklistItem', () => {
describe('Blacklist', () => {
describe('#fromJSON', () => {
it('parses string list', () => {
- let blacklist = Blacklist.fromJSON(['example.com', 'example.org']);
+ const blacklist = Blacklist.fromJSON(['example.com', 'example.org']);
expect(blacklist.toJSON()).to.deep.equals([
'example.com', 'example.org',
]);
});
it('parses mixed blacklist', () => {
- let blacklist = Blacklist.fromJSON([
+ const blacklist = Blacklist.fromJSON([
{ url: 'example.com', keys: ['j', 'k']},
'example.org',
]);
@@ -115,29 +105,21 @@ describe('Blacklist', () => {
});
it('parses empty blacklist', () => {
- let blacklist = Blacklist.fromJSON([]);
+ const blacklist = Blacklist.fromJSON([]);
expect(blacklist.toJSON()).to.deep.equals([]);
});
-
- it('throws a TypeError', () => {
- expect(() => Blacklist.fromJSON(null)).to.throw(TypeError);
- expect(() => Blacklist.fromJSON(100)).to.throw(TypeError);
- expect(() => Blacklist.fromJSON({})).to.throw(TypeError);
- expect(() => Blacklist.fromJSON([100])).to.throw(TypeError);
- expect(() => Blacklist.fromJSON([{}])).to.throw(TypeError);
- })
});
describe('#includesEntireBlacklist', () => {
it('matches a url with entire blacklist', () => {
- let blacklist = Blacklist.fromJSON(['google.com', '*.github.com']);
+ 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', () => {
- let blacklist = Blacklist.fromJSON(['google.com', { url: 'yahoo.com', keys: ['j', 'k'] }]);
+ 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;
});
@@ -145,7 +127,7 @@ describe('Blacklist', () => {
describe('#includesKeys', () => {
it('matches with entire blacklist or keys in the partial blacklist', () => {
- let blacklist = Blacklist.fromJSON([
+ const blacklist = Blacklist.fromJSON([
'google.com',
{ url: 'github.com', keys: ['j', 'k'] },
]);
diff --git a/test/shared/settings/Key.test.ts b/test/shared/settings/Key.test.ts
index 8222d5a..3a1c86e 100644
--- a/test/shared/settings/Key.test.ts
+++ b/test/shared/settings/Key.test.ts
@@ -4,7 +4,7 @@ import Key from '../../../src/shared/settings/Key';
describe("Key", () => {
describe('fromMapKey', () => {
it('return for X', () => {
- let key = Key.fromMapKey('x');
+ const key = Key.fromMapKey('x');
expect(key.key).to.equal('x');
expect(key.shift).to.be.false;
expect(key.ctrl).to.be.false;
@@ -13,7 +13,7 @@ describe("Key", () => {
});
it('return for Shift+X', () => {
- let key = Key.fromMapKey('X');
+ const key = Key.fromMapKey('X');
expect(key.key).to.equal('X');
expect(key.shift).to.be.true;
expect(key.ctrl).to.be.false;
@@ -22,7 +22,7 @@ describe("Key", () => {
});
it('return for Ctrl+X', () => {
- let key = Key.fromMapKey('<C-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;
@@ -31,7 +31,7 @@ describe("Key", () => {
});
it('returns for Ctrl+Meta+X', () => {
- let key = Key.fromMapKey('<C-M-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;
@@ -40,7 +40,7 @@ describe("Key", () => {
});
it('returns for Ctrl+Shift+x', () => {
- let key = Key.fromMapKey('<C-S-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;
@@ -49,7 +49,7 @@ describe("Key", () => {
});
it('returns for Shift+Esc', () => {
- let key = Key.fromMapKey('<S-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;
@@ -58,7 +58,7 @@ describe("Key", () => {
});
it('returns for Ctrl+Esc', () => {
- let key = Key.fromMapKey('<C-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;
@@ -67,7 +67,7 @@ describe("Key", () => {
});
it('returns for Ctrl+Esc', () => {
- let key = Key.fromMapKey('<C-Space>');
+ const key = Key.fromMapKey('<C-Space>');
expect(key.key).to.equal('Space');
expect(key.shift).to.be.false;
expect(key.ctrl).to.be.true;
@@ -76,17 +76,30 @@ 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', shift: true }).isDigit()).to.be.true;
+
+ expect(new Key({ key: 'a' }).isDigit()).to.be.false;
+ expect(new Key({ key: '0' }).isDigit()).to.be.false;
+ })
+ });
+
describe('equals', () => {
- 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;
+ 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/KeySequence.test.ts b/test/shared/settings/KeySequence.test.ts
deleted file mode 100644
index 361cbd1..0000000
--- a/test/shared/settings/KeySequence.test.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import KeySequence from '../../../src/shared/settings/KeySequence';
-import { expect } from 'chai'
-import Key from "../../../src/shared/settings/Key";
-
-describe("KeySequence", () => {
- describe('#push', () => {
- it('append a key to the sequence', () => {
- let seq = new 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;
- })
- });
-
- describe('#startsWith', () => {
- it('returns true if the key sequence starts with param', () => {
- let seq = new KeySequence([
- Key.fromMapKey('g'),
- 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([
- Key.fromMapKey('g'), Key.fromMapKey('<S-U>'),
- ]))).to.be.true;
- expect(seq.startsWith(new KeySequence([
- Key.fromMapKey('g'), Key.fromMapKey('<S-U>'), Key.fromMapKey('x'),
- ]))).to.be.false;
- expect(seq.startsWith(new KeySequence([
- Key.fromMapKey('h'),
- ]))).to.be.false;
- });
-
- it('returns true if the empty sequence starts with an empty sequence', () => {
- let seq = new KeySequence([]);
-
- expect(seq.startsWith(new KeySequence([]))).to.be.true;
- expect(seq.startsWith(new KeySequence([
- Key.fromMapKey('h'),
- ]))).to.be.false;
- })
- });
-
- describe('#fromMapKeys', () => {
- it('returns mapped keys for Shift+Esc', () => {
- let 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;
- });
-
- it('returns mapped keys for a<C-B><A-C>d<M-e>', () => {
- let 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');
- });
- })
-});
diff --git a/test/shared/settings/Keymaps.test.ts b/test/shared/settings/Keymaps.test.ts
index 7896a63..dcea6e4 100644
--- a/test/shared/settings/Keymaps.test.ts
+++ b/test/shared/settings/Keymaps.test.ts
@@ -4,12 +4,12 @@ import { expect } from 'chai';
describe('Keymaps', () => {
describe('#valueOf', () => {
it('returns empty object by empty settings', () => {
- let keymaps = Keymaps.fromJSON({}).toJSON();
+ const keymaps = Keymaps.fromJSON({}).toJSON();
expect(keymaps).to.be.empty;
});
it('returns keymaps by valid settings', () => {
- let keymaps = Keymaps.fromJSON({
+ const keymaps = Keymaps.fromJSON({
k: { type: "scroll.vertically", count: -1 },
j: { type: "scroll.vertically", count: 1 },
}).toJSON();
@@ -19,7 +19,6 @@ describe('Keymaps', () => {
});
it('throws a TypeError by invalid settings', () => {
- expect(() => Keymaps.fromJSON(null)).to.throw(TypeError);
expect(() => Keymaps.fromJSON({
k: { type: "invalid.operation" },
})).to.throw(TypeError);
@@ -28,7 +27,7 @@ describe('Keymaps', () => {
describe('#combine', () => {
it('returns combined keymaps', () => {
- let keymaps = Keymaps.fromJSON({
+ const keymaps = Keymaps.fromJSON({
k: { type: "scroll.vertically", count: -1 },
j: { type: "scroll.vertically", count: 1 },
}).combine(Keymaps.fromJSON({
@@ -36,7 +35,7 @@ describe('Keymaps', () => {
N: { type: "find.prev" },
}));
- let 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 }],
@@ -46,7 +45,7 @@ describe('Keymaps', () => {
});
it('overrides current keymaps', () => {
- let keymaps = Keymaps.fromJSON({
+ const keymaps = Keymaps.fromJSON({
k: { type: "scroll.vertically", count: -1 },
j: { type: "scroll.vertically", count: 1 },
}).combine(Keymaps.fromJSON({
@@ -54,7 +53,7 @@ describe('Keymaps', () => {
j: { type: "find.prev" },
}));
- let 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 }],
diff --git a/test/shared/settings/Properties.test.ts b/test/shared/settings/Properties.test.ts
index 609a565..4639839 100644
--- a/test/shared/settings/Properties.test.ts
+++ b/test/shared/settings/Properties.test.ts
@@ -4,7 +4,7 @@ import { expect } from 'chai';
describe('Properties', () => {
describe('#propertiesValueOf', () => {
it('returns with default properties by empty settings', () => {
- let props = Properties.fromJSON({});
+ const props = Properties.fromJSON({});
expect(props).to.deep.equal({
hintchars: "abcdefghijklmnopqrstuvwxyz",
smoothscroll: false,
@@ -13,7 +13,7 @@ describe('Properties', () => {
});
it('returns properties by valid settings', () => {
- let props = Properties.fromJSON({
+ const props = Properties.fromJSON({
hintchars: "abcdefgh",
smoothscroll: false,
complete: "sbh"
diff --git a/test/shared/settings/Search.test.ts b/test/shared/settings/Search.test.ts
index 7c9134d..8bd8d89 100644
--- a/test/shared/settings/Search.test.ts
+++ b/test/shared/settings/Search.test.ts
@@ -3,7 +3,7 @@ import { expect } from 'chai';
describe('Search', () => {
it('returns search settings by valid settings', () => {
- let search = Search.fromJSON({
+ const search = Search.fromJSON({
default: 'google',
engines: {
'google': 'https://google.com/search?q={}',
@@ -26,19 +26,6 @@ describe('Search', () => {
});
it('throws a TypeError by invalid settings', () => {
- expect(() => Search.fromJSON(null)).to.throw(TypeError);
- expect(() => Search.fromJSON({})).to.throw(TypeError);
- expect(() => Search.fromJSON([])).to.throw(TypeError);
- expect(() => Search.fromJSON({
- default: 123,
- engines: {}
- })).to.throw(TypeError);
- expect(() => Search.fromJSON({
- default: 'google',
- engines: {
- 'google': 123456,
- }
- })).to.throw(TypeError);
expect(() => Search.fromJSON({
default: 'wikipedia',
engines: {
diff --git a/test/shared/settings/Settings.test.ts b/test/shared/settings/Settings.test.ts
index ab6af04..658132c 100644
--- a/test/shared/settings/Settings.test.ts
+++ b/test/shared/settings/Settings.test.ts
@@ -4,7 +4,7 @@ import { expect } from 'chai';
describe('Settings', () => {
describe('#valueOf', () => {
it('returns settings by valid settings', () => {
- let x = Settings.fromJSON({
+ const x = Settings.fromJSON({
keymaps: {},
"search": {
"default": "google",
@@ -39,7 +39,7 @@ describe('Settings', () => {
});
it('sets default settings', () => {
- let value = Settings.fromJSON({});
+ 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');
diff --git a/test/shared/urls.test.ts b/test/shared/urls.test.ts
index 3a3eea6..6206d03 100644
--- a/test/shared/urls.test.ts
+++ b/test/shared/urls.test.ts
@@ -36,6 +36,21 @@ describe("shared/commands/parsers", () => {
expect(parsers.searchUrl('std::vector', config))
.to.equal('https://google.com/search?q=std%3A%3Avector');
});
+
+ it('localhost urls', () => {
+ expect(parsers.searchUrl('localhost', config))
+ .to.equal('http://localhost');
+ expect(parsers.searchUrl('http://localhost', config))
+ .to.equal('http://localhost/');
+ expect(parsers.searchUrl('localhost:8080', config))
+ .to.equal('http://localhost:8080');
+ expect(parsers.searchUrl('localhost:80nan', config))
+ .to.equal('https://google.com/search?q=localhost%3A80nan');
+ expect(parsers.searchUrl('localhost 8080', config))
+ .to.equal('https://google.com/search?q=localhost%208080');
+ expect(parsers.searchUrl('localhost:80/build', config))
+ .to.equal('http://localhost:80/build')
+ })
});
describe('#normalizeUrl', () => {
@@ -47,4 +62,3 @@ describe("shared/commands/parsers", () => {
});
});
});
-