aboutsummaryrefslogtreecommitdiff
path: root/test/shared
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-12-22 10:28:14 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-12-22 10:48:39 +0900
commit029d5365e7d74e87375fccb8db097b7c2df3f7f4 (patch)
tree6a24c719da9c60461c7e2fe120b0d42af9e580f2 /test/shared
parentd72012529bcd820598fa64e1aa20dab1c16acaa5 (diff)
npm run lint:fix
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.ts32
-rw-r--r--test/shared/settings/Key.test.ts16
-rw-r--r--test/shared/settings/Keymaps.test.ts12
-rw-r--r--test/shared/settings/Properties.test.ts4
-rw-r--r--test/shared/settings/Search.test.ts2
-rw-r--r--test/shared/settings/Settings.test.ts4
8 files changed, 57 insertions, 57 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 0112757..dfd036e 100644
--- a/test/shared/settings/Blacklist.test.ts
+++ b/test/shared/settings/Blacklist.test.ts
@@ -5,13 +5,13 @@ 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']);
@@ -20,12 +20,12 @@ describe('BlacklistItem', () => {
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;
@@ -34,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;
@@ -49,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;
@@ -57,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;
@@ -73,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;
@@ -87,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',
]);
@@ -105,21 +105,21 @@ describe('Blacklist', () => {
});
it('parses empty blacklist', () => {
- let blacklist = Blacklist.fromJSON([]);
+ const blacklist = Blacklist.fromJSON([]);
expect(blacklist.toJSON()).to.deep.equals([]);
});
});
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;
});
@@ -127,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 91a47f8..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;
diff --git a/test/shared/settings/Keymaps.test.ts b/test/shared/settings/Keymaps.test.ts
index 9e4109f..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();
@@ -27,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({
@@ -35,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 }],
@@ -45,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({
@@ -53,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 51cd3eb..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={}',
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');