diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-12-22 10:28:14 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-12-22 10:48:39 +0900 |
commit | 029d5365e7d74e87375fccb8db097b7c2df3f7f4 (patch) | |
tree | 6a24c719da9c60461c7e2fe120b0d42af9e580f2 | |
parent | d72012529bcd820598fa64e1aa20dab1c16acaa5 (diff) |
npm run lint:fix
70 files changed, 696 insertions, 696 deletions
diff --git a/e2e/blacklist.test.ts b/e2e/blacklist.test.ts index dec9d99..79cdb47 100644 --- a/e2e/blacklist.test.ts +++ b/e2e/blacklist.test.ts @@ -9,7 +9,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("blacklist test", () => { - let server = new TestServer().receiveContent('/*', + const server = new TestServer().receiveContent('/*', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -25,7 +25,7 @@ describe("blacklist test", () => { browser = lanthan.getWebExtBrowser(); await server.start(); - let url = server.url('/a').replace('http://', ''); + const url = server.url('/a').replace('http://', ''); await new SettingRepository(browser).saveJSON(Settings.fromJSON({ keymaps: { j: { type: "scroll.vertically", count: 1 }, @@ -42,18 +42,18 @@ describe("blacklist test", () => { }); it('should disable add-on if the URL is in the blacklist', async () => { - let page = await Page.navigateTo(webdriver, server.url('/a')); + const page = await Page.navigateTo(webdriver, server.url('/a')); await page.sendKeys('j'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 0); }); it('should enabled add-on if the URL is not in the blacklist', async () => { - let page = await Page.navigateTo(webdriver, server.url('/ab')); + const page = await Page.navigateTo(webdriver, server.url('/ab')); await page.sendKeys('j'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 64); }); }); diff --git a/e2e/clipboard.test.ts b/e2e/clipboard.test.ts index 3f2b289..0a09c77 100644 --- a/e2e/clipboard.test.ts +++ b/e2e/clipboard.test.ts @@ -11,7 +11,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("clipboard test", () => { - let server = new TestServer(12321).receiveContent('/happy', 'ok'); + const server = new TestServer(12321).receiveContent('/happy', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -44,18 +44,18 @@ describe("clipboard test", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); it('should copy current URL by y', async () => { - let page = await Page.navigateTo(webdriver, server.url('/#should_copy_url')); + const page = await Page.navigateTo(webdriver, server.url('/#should_copy_url')); await page.sendKeys('y'); await eventually(async() => { - let data = await clipboard.read(); + const data = await clipboard.read(); assert.strictEqual(data, server.url('/#should_copy_url')); }); }); @@ -63,11 +63,11 @@ describe("clipboard test", () => { it('should open an URL from clipboard by p', async () => { await clipboard.write(server.url('/#open_from_clipboard')); - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('p'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].url, server.url('/#open_from_clipboard')); }); }); @@ -75,11 +75,11 @@ describe("clipboard test", () => { it('should open an URL from clipboard to new tab by P', async () => { await clipboard.write(server.url('/#open_to_new_tab')); - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys(Key.SHIFT, 'p'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url(), server.url('/#open_to_new_tab'), @@ -90,11 +90,11 @@ describe("clipboard test", () => { it('should open search result with keywords in clipboard by p', async () => { await clipboard.write(`an apple`); - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys(Key.SHIFT, 'p'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].url, server.url('/google?q=an%20apple')); }); }); @@ -102,11 +102,11 @@ describe("clipboard test", () => { it('should open search result with keywords in clipboard to new tabby P', async () => { await clipboard.write(`an apple`); - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys(Key.SHIFT, 'p'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url(), server.url('/google?q=an%20apple'), diff --git a/e2e/command_addbookmark.test.ts b/e2e/command_addbookmark.test.ts index 5344292..a54c103 100644 --- a/e2e/command_addbookmark.test.ts +++ b/e2e/command_addbookmark.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe('addbookmark command test', () => { - let server = new TestServer().receiveContent('/happy', ` + const server = new TestServer().receiveContent('/happy', ` <!DOCTYPE html> <html lang="en"><head><title>how to be happy</title></head></html>`, ); @@ -38,12 +38,12 @@ describe('addbookmark command test', () => { }); it('should add a bookmark from the current page', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('addbookmark how to be happy'); await eventually(async() => { - var bookmarks = await browser.bookmarks.search({ title: 'how to be happy' }); + const bookmarks = await browser.bookmarks.search({ title: 'how to be happy' }); assert.strictEqual(bookmarks.length, 1); assert.strictEqual(bookmarks[0].url, server.url('/happy')); }); diff --git a/e2e/command_bdelete.test.ts b/e2e/command_bdelete.test.ts index 239074e..c1f27ae 100644 --- a/e2e/command_bdelete.test.ts +++ b/e2e/command_bdelete.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe('bdelete/bdeletes command test', () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -31,8 +31,8 @@ describe('bdelete/bdeletes command test', () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } await browser.tabs.update(tabs[0].id, { url: server.url('/site1'), pinned: true }); @@ -42,19 +42,19 @@ describe('bdelete/bdeletes command test', () => { await browser.tabs.create({ url: server.url('/site5'), }); await eventually(async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); }); it('should delete an unpinned tab by bdelete command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete site5'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url('/site1'), server.url('/site2'), @@ -65,45 +65,45 @@ describe('bdelete/bdeletes command test', () => { }); it('should not delete an pinned tab by bdelete command by bdelete command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete site1'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 5); }); }); it('should show an error when no tabs are matched by bdelete command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete xyz'); await eventually(async() => { - let text = await console.getErrorMessage(); + const text = await console.getErrorMessage(); assert.strictEqual(text, 'No matching buffer for xyz'); }); }); it('should show an error when more than one tabs are matched by bdelete command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete site'); await eventually(async() => { - let text = await console.getErrorMessage(); + const text = await console.getErrorMessage(); assert.strictEqual(text, 'More than one match for site'); }); }); it('should delete an unpinned tab by bdelete! command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete! site5'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url('/site1'), server.url('/site2'), @@ -114,12 +114,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete an pinned tab by bdelete! command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdelete! site1'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url('/site2'), server.url('/site3'), @@ -130,12 +130,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete unpinned tabs by bdeletes command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdeletes site'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.deepStrictEqual(tabs.map((t: any) => t.url), [ server.url('/site1'), server.url('/site2'), @@ -145,12 +145,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete both pinned and unpinned tabs by bdeletes! command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('bdeletes! site'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 1); }); }); diff --git a/e2e/command_buffer.test.ts b/e2e/command_buffer.test.ts index 472502b..3fa67ba 100644 --- a/e2e/command_buffer.test.ts +++ b/e2e/command_buffer.test.ts @@ -9,7 +9,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe('buffer command test', () => { - let server = new TestServer().handle('/*', (req: Request, res: Response) => { + const server = new TestServer().handle('/*', (req: Request, res: Response) => { res.send(` <!DOCTYPE html> <html lang="en"> @@ -40,8 +40,8 @@ describe('buffer command test', () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } await browser.tabs.update(tabs[0].id, { url: server.url('/site1') }); @@ -50,41 +50,41 @@ describe('buffer command test', () => { } await eventually(async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); }); it('should do nothing by buffer command with no parameters', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 2); }); }); it('should select a tab by buffer command with a number', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer 1'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); it('should should an out of range error by buffer commands', async() => { - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); let console = await page.showConsole(); await console.execCommand('buffer 0'); await eventually(async() => { - let text = await console.getErrorMessage(); + const text = await console.getErrorMessage(); assert.strictEqual(text, 'tab 0 does not exist'); }); @@ -94,68 +94,68 @@ describe('buffer command test', () => { await console.execCommand('buffer 9'); await eventually(async() => { - let text = await console.getErrorMessage(); + const text = await console.getErrorMessage(); assert.strictEqual(text, 'tab 9 does not exist'); }); }); it('should select a tab by buffer command with a title', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer my_site1'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); it('should select a tab by buffer command with an URL', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer /site1'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); it('should select tabs rotately', async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); await webdriver.switchTo().window(handles[4]); - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer site'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); it('should do nothing by ":buffer %"', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer %'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 2); }); }); it('should selects last selected tab by ":buffer #"', async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); await webdriver.switchTo().window(handles[1]); - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('buffer #'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 2); }); }); diff --git a/e2e/command_help.test.ts b/e2e/command_help.test.ts index 20035fd..9f8a459 100644 --- a/e2e/command_help.test.ts +++ b/e2e/command_help.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("help command test", () => { - let server = new TestServer(); + const server = new TestServer(); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -37,11 +37,11 @@ describe("help command test", () => { }); it('should open help page by help command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('help'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); + const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].url, 'https://ueokande.github.io/vim-vixen/') }); }); diff --git a/e2e/command_open.test.ts b/e2e/command_open.test.ts index ba9c51e..f4d2aa1 100644 --- a/e2e/command_open.test.ts +++ b/e2e/command_open.test.ts @@ -10,7 +10,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("open command test", () => { - let server = new TestServer() + const server = new TestServer() .receiveContent('/google', 'google') .receiveContent('/yahoo', 'yahoo'); let lanthan: Lanthan; @@ -51,67 +51,67 @@ describe("open command test", () => { }); it('should open default search for keywords by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open an apple'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/google?q=an%20apple')) }); }); it('should open certain search page for keywords by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open yahoo an apple'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/yahoo?q=an%20apple')) }); }); it('should open default engine with empty keywords by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/google?q=')) }); }); it('should open certain search page for empty keywords by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open yahoo'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/yahoo?q=')) }); }); it('should open a site with domain by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open example.com'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, 'http://example.com/') }); }); it('should open a site with URL by open command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('open https://example.com/'); await eventually(async() => { - let tabs = await browser.tabs.query({ active: true }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ active: true }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, 'https://example.com/') }); }); diff --git a/e2e/command_quit.test.ts b/e2e/command_quit.test.ts index 239d880..037ad09 100644 --- a/e2e/command_quit.test.ts +++ b/e2e/command_quit.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe('quit/quitall command test', () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -31,8 +31,8 @@ describe('quit/quitall command test', () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } await browser.tabs.update(tabs[0].id, { url: server.url('/site1') }); @@ -41,52 +41,52 @@ describe('quit/quitall command test', () => { } await eventually(async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); }); it('should current tab by q command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('q'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 4) }); }); it('should current tab by quit command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('quit'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 4) }); }); it('should current tab by qa command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('qa'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 1) }); }); it('should current tab by quitall command', async() => { - let page = await Page.currentContext(webdriver); - let console = await page.showConsole(); + const page = await Page.currentContext(webdriver); + const console = await page.showConsole(); await console.execCommand('quitall'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 1) }); }); diff --git a/e2e/command_tabopen.test.ts b/e2e/command_tabopen.test.ts index b5533e6..e96c29e 100644 --- a/e2e/command_tabopen.test.ts +++ b/e2e/command_tabopen.test.ts @@ -10,7 +10,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("tabopen command test", () => { - let server = new TestServer() + const server = new TestServer() .receiveContent('/google', 'google') .receiveContent('/yahoo', 'yahoo'); let lanthan: Lanthan; @@ -46,8 +46,8 @@ describe("tabopen command test", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } @@ -55,73 +55,73 @@ describe("tabopen command test", () => { }); it('should open default search for keywords by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen an apple'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, server.url('/google?q=an%20apple') ) }); }); it('should open certain search page for keywords by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen yahoo an apple'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, server.url('/yahoo?q=an%20apple')) }); }); it('should open default engine with empty keywords by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, server.url('/google?q=')) }); }); it('should open certain search page for empty keywords by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen yahoo'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, server.url('/yahoo?q=')) }); }); it('should open a site with domain by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen example.com'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, 'http://example.com/') }); }); it('should open a site with URL by tabopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('tabopen https://example.com/'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); - let url = new URL(tabs[1].url); + const url = new URL(tabs[1].url); assert.strictEqual(url.href, 'https://example.com/') }); }); diff --git a/e2e/command_winopen.test.ts b/e2e/command_winopen.test.ts index fb1348d..c9ff8d2 100644 --- a/e2e/command_winopen.test.ts +++ b/e2e/command_winopen.test.ts @@ -10,7 +10,7 @@ import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("winopen command test", () => { - let server = new TestServer() + const server = new TestServer() .receiveContent('/google', 'google') .receiveContent('/yahoo', 'yahoo'); let lanthan: Lanthan; @@ -46,8 +46,8 @@ describe("winopen command test", () => { }); beforeEach(async() => { - let wins = await browser.windows.getAll(); - for (let win of wins.slice(1)) { + const wins = await browser.windows.getAll(); + for (const win of wins.slice(1)) { await browser.windows.remove(win.id); } @@ -55,85 +55,85 @@ describe("winopen command test", () => { }); it('should open default search for keywords by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen an apple'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/google?q=an%20apple')) }); }); it('should open certain search page for keywords by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen yahoo an apple'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/yahoo?q=an%20apple')) }); }); it('should open default engine with empty keywords by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/google?q=')) }); }); it('should open certain search page for empty keywords by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen yahoo'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, server.url('/yahoo?q=')) }); }); it('should open a site with domain by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen example.com'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, 'http://example.com/') }); }); it('should open a site with URL by winopen command ', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('winopen https://example.com/'); await eventually(async() => { - let wins = await browser.windows.getAll(); + const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); - let tabs = await browser.tabs.query({ windowId: wins[1].id }); - let url = new URL(tabs[0].url); + const tabs = await browser.tabs.query({ windowId: wins[1].id }); + const url = new URL(tabs[0].url); assert.strictEqual(url.href, 'https://example.com/') }); }); diff --git a/e2e/completion.test.ts b/e2e/completion.test.ts index e98e1c2..dd4477f 100644 --- a/e2e/completion.test.ts +++ b/e2e/completion.test.ts @@ -30,9 +30,9 @@ describe("general completion test", () => { }); it('should all commands on empty line', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 11); assert.deepStrictEqual(items[0], { type: 'title', text: 'Console Command' }); assert.ok(items[1].text.startsWith('set')); @@ -41,10 +41,10 @@ describe("general completion test", () => { }); it('should only commands filtered by prefix', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('b'); - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 4); assert.deepStrictEqual(items[0], { type: 'title', text: 'Console Command' }); assert.ok(items[1].text.startsWith('buffer')); @@ -57,23 +57,23 @@ describe("general completion test", () => { // > bdeletes // : b it('selects completion items by <Tab>/<S-Tab> keys', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('b'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 4); }); await console.sendKeys(Key.TAB); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.ok(items[1].highlight); assert.strictEqual(await console.currentValue(), 'buffer'); }); await console.sendKeys(Key.TAB, Key.TAB); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.ok(items[3].highlight); assert.strictEqual(await console.currentValue(), 'bdeletes'); }); @@ -85,7 +85,7 @@ describe("general completion test", () => { await console.sendKeys(Key.SHIFT, Key.TAB); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.ok(items[3].highlight); assert.strictEqual(await console.currentValue(), 'bdeletes'); }); diff --git a/e2e/completion_buffers.test.ts b/e2e/completion_buffers.test.ts index b6e7de0..ac24753 100644 --- a/e2e/completion_buffers.test.ts +++ b/e2e/completion_buffers.test.ts @@ -9,7 +9,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("completion on buffer/bdelete/bdeletes", () => { - let server = new TestServer().handle('/*', (req: Request, res: Response) => { + const server = new TestServer().handle('/*', (req: Request, res: Response) => { res.send(` <!DOCTYPE html> <html lang="en"> @@ -42,8 +42,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } @@ -54,7 +54,7 @@ describe("completion on buffer/bdelete/bdeletes", () => { } await eventually(async() => { - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); @@ -63,11 +63,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should all tabs by "buffer" command with empty params', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('buffer '); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 6); assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); assert.ok(items[1].text.startsWith('1:')); @@ -82,11 +82,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should filter items with URLs by keywords on "buffer" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('buffer title_site2'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); assert.ok(items[1].text.startsWith('2:')); assert.ok(items[1].text.includes('title_site2')); @@ -95,22 +95,22 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should filter items with titles by keywords on "buffer" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('buffer /site2'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); assert.ok(items[1].text.startsWith('2:')); }); }); it('should show one item by number on "buffer" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('buffer 2'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 2); assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); assert.ok(items[1].text.startsWith('2:')); @@ -118,11 +118,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should show unpinned tabs "bdelete" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('bdelete site'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 4); assert.ok(items[1].text.includes('site3')); assert.ok(items[2].text.includes('site4')); @@ -131,11 +131,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should show unpinned tabs "bdeletes" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('bdeletes site'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 4); assert.ok(items[1].text.includes('site3')); assert.ok(items[2].text.includes('site4')); @@ -144,11 +144,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should show both pinned and unpinned tabs "bdelete!" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('bdelete! site'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 6); assert.ok(items[1].text.includes('site1')); assert.ok(items[2].text.includes('site2')); @@ -159,11 +159,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { }); it('should show both pinned and unpinned tabs "bdeletes!" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('bdeletes! site'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 6); assert.ok(items[1].text.includes('site1')); assert.ok(items[2].text.includes('site2')); diff --git a/e2e/completion_open.test.ts b/e2e/completion_open.test.ts index ab9d191..95d4175 100644 --- a/e2e/completion_open.test.ts +++ b/e2e/completion_open.test.ts @@ -10,7 +10,7 @@ import Page from './lib/Page'; import SettingRepository from "./lib/SettingRepository"; describe("completion on open/tabopen/winopen commands", () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -42,11 +42,11 @@ describe("completion on open/tabopen/winopen commands", () => { }); it('should show completions from search engines, bookmarks, and histories by "open" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); + const completions = await console.getCompletions(); assert.ok(completions.find(x => x.type === 'title' && x.text === 'Search Engines')); assert.ok(completions.find(x => x.type === 'title' && x.text === 'Bookmarks')); assert.ok(completions.find(x => x.type === 'title' && x.text === 'History')); @@ -54,45 +54,45 @@ describe("completion on open/tabopen/winopen commands", () => { }); it('should filter items with URLs by keywords on "open" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('open https://'); await eventually(async() => { - let completions = await console.getCompletions(); - let items = completions.filter(x => x.type === 'item').map(x => x.text); + const completions = await console.getCompletions(); + const items = completions.filter(x => x.type === 'item').map(x => x.text); assert.ok(items.every(x => x.includes('https://'))); }); }); it('should filter items with titles by keywords on "open" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('open getting'); await eventually(async() => { - let completions = await console.getCompletions(); - let items = completions.filter(x => x.type === 'item').map(x => x.text); + const completions = await console.getCompletions(); + const items = completions.filter(x => x.type === 'item').map(x => x.text); assert.ok(items.every(x => x.toLowerCase().includes('getting'))); }); }); it('should filter items with titles by keywords on "tabopen" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('tabopen getting'); await eventually(async() => { - let completions = await console.getCompletions(); - let items = completions.filter(x => x.type === 'item').map(x => x.text); + const completions = await console.getCompletions(); + const items = completions.filter(x => x.type === 'item').map(x => x.text); assert.ok(items.every(x => x.includes('https://'))); }); }); it('should filter items with titles by keywords on "winopen" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('winopen https://'); await eventually(async() => { - let completions = await console.getCompletions(); - let items = completions.filter(x => x.type === 'item').map(x => x.text); + const completions = await console.getCompletions(); + const items = completions.filter(x => x.type === 'item').map(x => x.text); assert.ok(items.every(x => x.includes('https://'))); }); }); @@ -106,8 +106,8 @@ describe("completion on open/tabopen/winopen commands", () => { await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); - let titles = completions.filter(x => x.type === 'title').map(x => x.text); + const completions = await console.getCompletions(); + const titles = completions.filter(x => x.type === 'title').map(x => x.text); assert.deepStrictEqual(titles, ['Search Engines', 'Bookmarks', 'History']) }); @@ -120,8 +120,8 @@ describe("completion on open/tabopen/winopen commands", () => { await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); - let titles = completions.filter(x => x.type === 'title').map(x => x.text); + const completions = await console.getCompletions(); + const titles = completions.filter(x => x.type === 'title').map(x => x.text); assert.deepStrictEqual(titles, ['Bookmarks', 'Search Engines', 'Search Engines']) }); }); @@ -135,8 +135,8 @@ describe("completion on open/tabopen/winopen commands", () => { await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); - let titles = completions.filter(x => x.type === 'title').map(x => x.text); + const completions = await console.getCompletions(); + const titles = completions.filter(x => x.type === 'title').map(x => x.text); assert.deepStrictEqual(titles, ['Search Engines', 'Bookmarks', 'History']) }); @@ -151,8 +151,8 @@ describe("completion on open/tabopen/winopen commands", () => { await console.inputKeys('open '); await eventually(async() => { - let completions = await console.getCompletions(); - let titles = completions.filter(x => x.type === 'title').map(x => x.text); + const completions = await console.getCompletions(); + const titles = completions.filter(x => x.type === 'title').map(x => x.text); assert.deepStrictEqual(titles, ['Bookmarks', 'Search Engines', 'Search Engines']) }); }); diff --git a/e2e/completion_set.test.ts b/e2e/completion_set.test.ts index facf991..7e9714c 100644 --- a/e2e/completion_set.test.ts +++ b/e2e/completion_set.test.ts @@ -30,11 +30,11 @@ describe("completion on set commands", () => { }); it('should show all property names by "set" command with empty params', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('set '); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 5); assert.deepStrictEqual(items[0], { type: 'title', text: 'Properties' }); assert.ok(items[1].text.startsWith('hintchars')); @@ -45,11 +45,11 @@ describe("completion on set commands", () => { }); it('should show filtered property names by "set" command', async() => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.inputKeys('set no'); await eventually(async() => { - let items = await console.getCompletions(); + const items = await console.getCompletions(); assert.strictEqual(items.length, 2); assert.ok(items[1].text.includes('nosmoothscroll')) }); diff --git a/e2e/console.test.ts b/e2e/console.test.ts index faaf695..1d441f9 100644 --- a/e2e/console.test.ts +++ b/e2e/console.test.ts @@ -7,7 +7,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; describe("console test", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><head><title>Hello, world!</title></head></html>`, ); let lanthan: Lanthan; @@ -36,55 +36,55 @@ describe("console test", () => { it('open console with :', async() => { await page.sendKeys(':'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), ''); }); it('open console with open command by o', async() => { await page.sendKeys('o'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), 'open '); }); it('open console with open command and current URL by O', async() => { await page.sendKeys(Key.SHIFT, 'o'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `open ${server.url()}`); }); it('open console with tabopen command by t', async() => { await page.sendKeys('t'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), 'tabopen '); }); it('open console with tabopen command and current URL by T', async() => { await page.sendKeys(Key.SHIFT, 't'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `tabopen ${server.url()}`); }); it('open console with winopen command by w', async() => { await page.sendKeys('w'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `winopen `); }); it('open console with winopen command and current URL by W', async() => { await page.sendKeys(Key.SHIFT, 'W'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `winopen ${server.url()}`); }); it('open console with buffer command by b', async() => { await page.sendKeys('b'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `buffer `); }); it('open console with addbookmark command with title by a', async() => { await page.sendKeys('a'); - let console = await page.getConsole(); + const console = await page.getConsole(); assert.strictEqual(await console.currentValue(), `addbookmark Hello, world!`); }); }); diff --git a/e2e/eventually.ts b/e2e/eventually.ts index 12c4552..b0a2dfc 100644 --- a/e2e/eventually.ts +++ b/e2e/eventually.ts @@ -12,8 +12,8 @@ const eventually = async ( timeout = defaultTimeout, interval = defaultInterval, ): Promise<void> => { - let start = Date.now(); - let loop = async() => { + const start = Date.now(); + const loop = async() => { try { await fn(); } catch (err) { diff --git a/e2e/follow.test.ts b/e2e/follow.test.ts index ce3f565..62a109f 100644 --- a/e2e/follow.test.ts +++ b/e2e/follow.test.ts @@ -8,7 +8,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; const newApp = () => { - let server = new TestServer(); + const server = new TestServer(); server.receiveContent('/', ` <!DOCTYPE html> @@ -105,7 +105,7 @@ const newApp = () => { }; describe('follow test', () => { - let server = newApp(); + const server = newApp(); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -128,52 +128,52 @@ describe('follow test', () => { }); afterEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); it('should focus an input by f', async () => { - let page = await Page.navigateTo(webdriver, server.url('/follow-input')); + const page = await Page.navigateTo(webdriver, server.url('/follow-input')); await page.sendKeys('f'); await page.waitAndGetHints(); await page.sendKeys('a'); - let tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string; + const tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string; assert.strictEqual(tagName.toLowerCase(), 'input'); }); it('should open a link by f', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('f'); await page.waitAndGetHints(); await page.sendKeys('a'); await eventually(async() => { - let hash = await webdriver.executeScript('return location.pathname'); + const hash = await webdriver.executeScript('return location.pathname'); assert.strictEqual(hash, '/hello'); }); }); it('should focus an input by F', async () => { - let page = await Page.navigateTo(webdriver, server.url('/follow-input')); + const page = await Page.navigateTo(webdriver, server.url('/follow-input')); await page.sendKeys(Key.SHIFT, 'f'); await page.waitAndGetHints(); await page.sendKeys('a'); - let tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string; + const tagName = await webdriver.executeScript(() => document.activeElement!!.tagName) as string; assert.strictEqual(tagName.toLowerCase(), 'input'); }); it('should open a link to new tab by F', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys(Key.SHIFT, 'f'); await page.waitAndGetHints(); await page.sendKeys('a'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); assert.strictEqual(new URL(tabs[1].url).pathname, '/hello'); assert.strictEqual(tabs[1].openerTabId, tabs[0].id); @@ -181,36 +181,36 @@ describe('follow test', () => { }); it('should show hints of links in area', async () => { - let page = await Page.navigateTo(webdriver, server.url('/area')); + const page = await Page.navigateTo(webdriver, server.url('/area')); await page.sendKeys(Key.SHIFT, 'f'); - let hints = await page.waitAndGetHints(); + const hints = await page.waitAndGetHints(); assert.strictEqual(hints.length, 3); }); it('should shows hints only in viewport', async () => { - let page = await Page.navigateTo(webdriver, server.url('/test1')); + const page = await Page.navigateTo(webdriver, server.url('/test1')); await page.sendKeys(Key.SHIFT, 'f'); - let hints = await page.waitAndGetHints(); + const hints = await page.waitAndGetHints(); assert.strictEqual(hints.length, 1); }); it('should shows hints only in window of the frame', async () => { - let page = await Page.navigateTo(webdriver, server.url('/test2')); + const page = await Page.navigateTo(webdriver, server.url('/test2')); await page.sendKeys(Key.SHIFT, 'f'); await webdriver.switchTo().frame(0); - let hints = await page.waitAndGetHints(); + const hints = await page.waitAndGetHints(); assert.strictEqual(hints.length, 1); }); it('should shows hints only in the frame', async () => { - let page = await Page.navigateTo(webdriver, server.url('/test3')); + const page = await Page.navigateTo(webdriver, server.url('/test3')); await page.sendKeys(Key.SHIFT, 'f'); await webdriver.switchTo().frame(0); - let hints = await page.waitAndGetHints(); + const hints = await page.waitAndGetHints(); assert.strictEqual(hints.length, 1); }); }); diff --git a/e2e/follow_properties.test.ts b/e2e/follow_properties.test.ts index eaa38e2..bbd46d4 100644 --- a/e2e/follow_properties.test.ts +++ b/e2e/follow_properties.test.ts @@ -8,7 +8,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; describe('follow properties test', () => { - let server = new TestServer().receiveContent('/', ` + const server = new TestServer().receiveContent('/', ` <!DOCTYPE html> <html lang="en"><body> <a href="/">link1</a> @@ -65,8 +65,8 @@ describe('follow properties test', () => { }); afterEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); @@ -99,7 +99,7 @@ describe('follow properties test', () => { await page.sendKeys('jj'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs[0].active, false); assert.strictEqual(tabs[1].active, true); }); @@ -111,14 +111,14 @@ describe('follow properties test', () => { await page.sendKeys('jj'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs[0].active, true); assert.strictEqual(tabs[1].active, false); }); }); it('should show hints with hintchars by settings', async () => { - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand('set hintchars=abc'); await (webdriver.switchTo() as any).parentFrame(); diff --git a/e2e/lib/Console.ts b/e2e/lib/Console.ts index 233bf48..6a82387 100644 --- a/e2e/lib/Console.ts +++ b/e2e/lib/Console.ts @@ -11,13 +11,13 @@ export class Console { } async sendKeys(...keys: string[]) { - let input = await this.webdriver.findElement(By.css('input')); + const input = await this.webdriver.findElement(By.css('input')); input.sendKeys(...keys); } async currentValue() { return await this.webdriver.executeScript(() => { - let input = document.querySelector('input'); + const input = document.querySelector('input'); if (input === null) { throw new Error('could not find input element'); } @@ -26,33 +26,33 @@ export class Console { } async execCommand(command: string): Promise<void> { - let input = await this.webdriver.findElement(By.css('input.vimvixen-console-command-input')); + const input = await this.webdriver.findElement(By.css('input.vimvixen-console-command-input')); await input.sendKeys(command, Key.ENTER); } async getErrorMessage(): Promise<string> { - let p = await this.webdriver.findElement(By.css('.vimvixen-console-error')); + const p = await this.webdriver.findElement(By.css('.vimvixen-console-error')); return p.getText(); } async inputKeys(...keys: string[]) { - let input = await this.webdriver.findElement(By.css('input')); + const input = await this.webdriver.findElement(By.css('input')); await input.sendKeys(...keys); } getCompletions(): Promise<CompletionItem[]> { return this.webdriver.executeScript(() => { - let items = document.querySelectorAll('.vimvixen-console-completion > li'); + const items = document.querySelectorAll('.vimvixen-console-completion > li'); if (items.length === 0) { throw new Error('completion items not found'); } - let objs = []; - for (let li of Array.from(items)) { + const objs = []; + for (const li of Array.from(items)) { if (li.classList.contains('vimvixen-console-completion-title')) { objs.push({ type: 'title', text: li.textContent!!.trim() }); } else if ('vimvixen-console-completion-item') { - let highlight = li.classList.contains('vimvixen-completion-selected'); + const highlight = li.classList.contains('vimvixen-completion-selected'); objs.push({ type: 'item', text: li.textContent!!.trim(), highlight }); } else { throw new Error(`unexpected class: ${li.className}`); @@ -63,7 +63,7 @@ export class Console { } async close(): Promise<void> { - let input = await this.webdriver.findElement(By.css('input')); + const input = await this.webdriver.findElement(By.css('input')); await input.sendKeys(Key.ESCAPE); // TODO remove sleep await new Promise(resolve => setTimeout(resolve, 100)); diff --git a/e2e/lib/FormOptionPage.ts b/e2e/lib/FormOptionPage.ts index 7d981f4..33ce2a7 100644 --- a/e2e/lib/FormOptionPage.ts +++ b/e2e/lib/FormOptionPage.ts @@ -9,8 +9,8 @@ export default class FormOptionPage { } async setBlacklist(nth: number, url: string): Promise<void> { - let selector = '.form-blacklist-form-row > .column-url'; - let inputs = await this.webdriver.findElements(By.css(selector)); + const selector = '.form-blacklist-form-row > .column-url'; + const inputs = await this.webdriver.findElements(By.css(selector)); if (inputs.length <= nth) { throw new RangeError('Index out of range to set a blacklist') } @@ -55,21 +55,21 @@ export default class FormOptionPage { } async addBlacklist(): Promise<void> { - let rows = await this.webdriver.findElements(By.css(`.form-blacklist-form-row`)); - let button = await this.webdriver.findElement(By.css('.form-blacklist-form .ui-add-button')) + const rows = await this.webdriver.findElements(By.css(`.form-blacklist-form-row`)); + const button = await this.webdriver.findElement(By.css('.form-blacklist-form .ui-add-button')) await button.click(); await this.webdriver.wait(until.elementLocated(By.css(`.form-blacklist-form-row:nth-child(${rows.length + 1})`))); } async addPartialBlacklist(): Promise<void> { - let rows = await this.webdriver.findElements(By.css(`.form-partial-blacklist-form-row`)); - let button = await this.webdriver.findElement(By.css('.form-partial-blacklist-form .ui-add-button')) + const rows = await this.webdriver.findElements(By.css(`.form-partial-blacklist-form-row`)); + const button = await this.webdriver.findElement(By.css('.form-partial-blacklist-form .ui-add-button')) await button.click(); await this.webdriver.wait(until.elementLocated(By.css(`.form-partial-blacklist-form-row:nth-child(${rows.length + 2})`))); } async removeBlackList(nth: number): Promise<void> { - let buttons = await this.webdriver.findElements(By.css('.form-blacklist-form-row .ui-delete-button')); + const buttons = await this.webdriver.findElements(By.css('.form-blacklist-form-row .ui-delete-button')); if (buttons.length <= nth) { throw new RangeError('Index out of range to remove blacklist') } @@ -77,7 +77,7 @@ export default class FormOptionPage { } async removePartialBlackList(nth: number): Promise<void> { - let buttons = await this.webdriver.findElements(By.css('.form-partial-blacklist-form-row .ui-delete-button')); + const buttons = await this.webdriver.findElements(By.css('.form-partial-blacklist-form-row .ui-delete-button')); if (buttons.length <= nth) { throw new RangeError('Index out of range to remove partial blacklist') } @@ -85,14 +85,14 @@ export default class FormOptionPage { } async addSearchEngine(): Promise<void> { - let rows = await this.webdriver.findElements(By.css(`.form-search-form-row > .column-name`)); - let button = await this.webdriver.findElement(By.css('.form-search-form > .ui-add-button')) + const rows = await this.webdriver.findElements(By.css(`.form-search-form-row > .column-name`)); + const button = await this.webdriver.findElement(By.css('.form-search-form > .ui-add-button')) await button.click(); await this.webdriver.wait(until.elementLocated(By.css(`.form-search-form-row:nth-child(${rows.length + 1})`))); } async setDefaultSearchEngine(nth: number): Promise<void> { - let radios = await this.webdriver.findElements(By.css('.form-search-form-row input[type=radio]')); + const radios = await this.webdriver.findElements(By.css('.form-search-form-row input[type=radio]')); if (radios.length <= nth) { throw new RangeError('Index out of range to set a default search engine'); } diff --git a/e2e/lib/JSONOptionPage.ts b/e2e/lib/JSONOptionPage.ts index ac1ae3d..d6ed7ee 100644 --- a/e2e/lib/JSONOptionPage.ts +++ b/e2e/lib/JSONOptionPage.ts @@ -9,14 +9,14 @@ export default class JSONOptionPage { } async updateSettings(value: string): Promise<void> { - let textarea = await this.webdriver.findElement(By.css('textarea')); + const textarea = await this.webdriver.findElement(By.css('textarea')); await this.webdriver.executeScript(`document.querySelector('textarea').value = '${value}'`) await textarea.sendKeys(' '); await this.webdriver.executeScript(() => document.querySelector('textarea')!!.blur()); } async getErrorMessage(): Promise<string> { - let error = await this.webdriver.findElement(By.css('.settings-ui-input-error')); + const error = await this.webdriver.findElement(By.css('.settings-ui-input-error')); return error.getText(); } } diff --git a/e2e/lib/OptionPage.ts b/e2e/lib/OptionPage.ts index c183b06..9f994a0 100644 --- a/e2e/lib/OptionPage.ts +++ b/e2e/lib/OptionPage.ts @@ -11,13 +11,13 @@ export default class OptionPage { } static async open(lanthan: Lanthan) { - let url = await lanthan.getWebExtBrowser().runtime.getURL("build/settings.html") + const url = await lanthan.getWebExtBrowser().runtime.getURL("build/settings.html") await lanthan.getWebDriver().navigate().to(url); return new OptionPage(lanthan); } async switchToForm(): Promise<FormOptionPage> { - let useFormInput = await this.webdriver.findElement(By.css('#setting-source-form')); + const useFormInput = await this.webdriver.findElement(By.css('#setting-source-form')); await useFormInput.click(); await this.webdriver.switchTo().alert().accept(); return new FormOptionPage(this.lanthan); diff --git a/e2e/lib/Page.ts b/e2e/lib/Page.ts index 7a5dd7a..ad3f454 100644 --- a/e2e/lib/Page.ts +++ b/e2e/lib/Page.ts @@ -22,7 +22,7 @@ export default class Page { } async sendKeys(...keys: Array<string|number|Promise<string|number>>): Promise<void> { - let body = await this.webdriver.findElement(By.css('body')); + const body = await this.webdriver.findElement(By.css('body')); await body.sendKeys(...keys); } @@ -33,7 +33,7 @@ export default class Page { } async showConsole(): Promise<Console> { - let iframe = this.webdriver.findElement(By.css('#vimvixen-console-frame')); + const iframe = this.webdriver.findElement(By.css('#vimvixen-console-frame')); await this.sendKeys(':'); await this.webdriver.wait(until.elementIsVisible(iframe)); @@ -43,7 +43,7 @@ export default class Page { } async getConsole(): Promise<Console> { - let iframe = this.webdriver.findElement(By.css('#vimvixen-console-frame')); + const iframe = this.webdriver.findElement(By.css('#vimvixen-console-frame')); await this.webdriver.wait(until.elementIsVisible(iframe)); await this.webdriver.switchTo().frame(0); @@ -69,11 +69,11 @@ export default class Page { async waitAndGetHints(): Promise<Hint[]> { await this.webdriver.wait(until.elementsLocated(By.css('.vimvixen-hint'))); - let elements = await this.webdriver.findElements(By.css(`.vimvixen-hint`)); - let hints = []; - for (let e of elements) { - let display = await e.getCssValue('display'); - let text = await e.getText(); + const elements = await this.webdriver.findElements(By.css(`.vimvixen-hint`)); + const hints = []; + for (const e of elements) { + const display = await e.getCssValue('display'); + const text = await e.getText(); hints.push({ displayed: display !== 'none', text: text, @@ -83,7 +83,7 @@ export default class Page { } private static async waitForConsoleLoaded(webdriver: WebDriver) { - let topFrame = await webdriver.executeScript(() => window.top === window); + const topFrame = await webdriver.executeScript(() => window.top === window); if (!topFrame) { return; } diff --git a/e2e/lib/TestServer.ts b/e2e/lib/TestServer.ts index c010e37..5b9eee3 100644 --- a/e2e/lib/TestServer.ts +++ b/e2e/lib/TestServer.ts @@ -28,12 +28,12 @@ export default class TestServer { return this; } - url(path: string = '/'): string { + url(path = '/'): string { if (!this.http) { throw new Error('http server not started'); } - let addr = this.http.address() as net.AddressInfo; + const addr = this.http.address() as net.AddressInfo; return `http://${addr.address}:${addr.port}${path}` } diff --git a/e2e/lib/clipboard.ts b/e2e/lib/clipboard.ts index c1eddbb..297b71a 100644 --- a/e2e/lib/clipboard.ts +++ b/e2e/lib/clipboard.ts @@ -3,7 +3,7 @@ import { spawn } from 'child_process'; const readLinux = (): Promise<string> => { let stdout = '', stderr = ''; return new Promise((resolve) => { - let xsel = spawn('xsel', ['--clipboard', '--output']); + const xsel = spawn('xsel', ['--clipboard', '--output']); xsel.stdout.on('data', (data) => { stdout += data; }); @@ -22,7 +22,7 @@ const readLinux = (): Promise<string> => { const writeLinux = (data: string): Promise<string> => { let stderr = ''; return new Promise((resolve) => { - let xsel = spawn('xsel', ['--clipboard', '--input']); + const xsel = spawn('xsel', ['--clipboard', '--input']); xsel.stderr.on('data', (data) => { stderr += data; }); @@ -40,7 +40,7 @@ const writeLinux = (data: string): Promise<string> => { const readDarwin = (): Promise<string> => { let stdout = '', stderr = ''; return new Promise((resolve) => { - let pbpaste = spawn('pbpaste'); + const pbpaste = spawn('pbpaste'); pbpaste.stdout.on('data', (data) => { stdout += data; }); @@ -59,7 +59,7 @@ const readDarwin = (): Promise<string> => { const writeDarwin = (data: string): Promise<string> => { let stderr = ''; return new Promise((resolve) => { - let pbcopy = spawn('pbcopy'); + const pbcopy = spawn('pbcopy'); pbcopy.stderr.on('data', (data) => { stderr += data; }); diff --git a/e2e/mark.test.ts b/e2e/mark.test.ts index f9f372b..c73423b 100644 --- a/e2e/mark.test.ts +++ b/e2e/mark.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("mark test", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -34,7 +34,7 @@ describe("mark test", () => { }); it('should set a local mark and jump to it', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.scrollTo(200, 200); await page.sendKeys('m', 'a'); await page.scrollTo(500, 500); @@ -63,8 +63,8 @@ describe("mark test", () => { await page.sendKeys('\'', 'A'); await eventually(async() => { - let tab = (await browser.tabs.query({ active: true }))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({ active: true }))[0]; + const url = new URL(tab.url); assert.strictEqual(url.hash, '#first'); assert.strictEqual(await page.getScrollX(), 200); @@ -77,7 +77,7 @@ describe("mark test", () => { await page.scrollTo(500, 500); await page.sendKeys('m', 'A'); - let tab = (await browser.tabs.query({ active: true }))[0]; + const tab = (await browser.tabs.query({ active: true }))[0]; await browser.tabs.create({ url: server.url('/#second') }); await browser.tabs.remove(tab.id); @@ -92,8 +92,8 @@ describe("mark test", () => { await page.sendKeys('\'', 'A'); await eventually(async() => { - let tab = (await browser.tabs.query({ active: true }))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({ active: true }))[0]; + const url = new URL(tab.url); assert.strictEqual(url.hash, '#first'); }); }); diff --git a/e2e/navigate.test.ts b/e2e/navigate.test.ts index 15c5a31..37f0520 100644 --- a/e2e/navigate.test.ts +++ b/e2e/navigate.test.ts @@ -9,7 +9,7 @@ import { Options as FirefoxOptions } from 'selenium-webdriver/firefox'; import Page from './lib/Page'; const newApp = () => { - let server = new TestServer(); + const server = new TestServer(); server.handle('/pagenation-a/:page', (req, res) => { res.status(200).send(` <!DOCTYPE html> @@ -44,7 +44,7 @@ const newApp = () => { }; describe("navigate test", () => { - let server = newApp(); + const server = newApp(); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -52,7 +52,7 @@ describe("navigate test", () => { before(async() => { await server.start(); - let opts = (new FirefoxOptions() as any) + const opts = (new FirefoxOptions() as any) .setPreference('browser.startup.homepage', server.url('/#home')); lanthan = await Builder .forBrowser('firefox') @@ -71,42 +71,42 @@ describe("navigate test", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); it('should go to parent path without hash by gu', async () => { - let page = await Page.navigateTo(webdriver, server.url('/a/b/c')); + const page = await Page.navigateTo(webdriver, server.url('/a/b/c')); await page.sendKeys('g', 'u'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, `/a/b/`) }); }); it('should remove hash by gu', async () => { - let page = await Page.navigateTo(webdriver, server.url('/a/b/c#hash')); + const page = await Page.navigateTo(webdriver, server.url('/a/b/c#hash')); await page.sendKeys('g', 'u'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.hash, ''); assert.strictEqual(url.pathname, `/a/b/c`) }); }); it('should go to root path by gU', async () => { - let page = await Page.navigateTo(webdriver, server.url('/a/b/c#hash')); + const page = await Page.navigateTo(webdriver, server.url('/a/b/c#hash')); await page.sendKeys('g', Key.SHIFT, 'u'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, `/`) }); }); @@ -117,8 +117,8 @@ describe("navigate test", () => { await page.sendKeys(Key.SHIFT, 'h'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, `/first`) }); @@ -126,73 +126,73 @@ describe("navigate test", () => { page.sendKeys(Key.SHIFT, 'l'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, `/second`) }); }); it('should go previous and next page in <a> by [[ and ]]', async () => { - let page = await Page.navigateTo(webdriver, server.url('/pagenation-a/10')); + const page = await Page.navigateTo(webdriver, server.url('/pagenation-a/10')); await page.sendKeys('[', '['); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, '/pagenation-a/9'); }); }); it('should go next page in <a> by ]]', async () => { - let page = await Page.navigateTo(webdriver, server.url('/pagenation-a/10')); + const page = await Page.navigateTo(webdriver, server.url('/pagenation-a/10')); await page.sendKeys(']', ']'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, '/pagenation-a/11'); }); }); it('should go previous page in <link> by ]]', async () => { - let page = await Page.navigateTo(webdriver, server.url('/pagenation-link/10')); + const page = await Page.navigateTo(webdriver, server.url('/pagenation-link/10')); await page.sendKeys('[', '['); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, '/pagenation-link/9'); }); }); it('should go next page by in <link> by [[', async () => { - let page = await Page.navigateTo(webdriver, server.url('/pagenation-link/10')); + const page = await Page.navigateTo(webdriver, server.url('/pagenation-link/10')); await page.sendKeys(']', ']'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.pathname, '/pagenation-link/11'); }); }); it('should go to home page into current tab by gh', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('g', 'h'); await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; - let url = new URL(tab.url); + const tab = (await browser.tabs.query({}))[0]; + const url = new URL(tab.url); assert.strictEqual(url.hash, '#home'); }); }); it('should go to home page into current tab by gH', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('g', Key.SHIFT, 'H'); await eventually(async() => { - let tabs = await browser.tabs.query({}); + const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); assert.strictEqual(new URL(tabs[0].url).hash, ''); assert.strictEqual(new URL(tabs[1].url).hash, '#home'); @@ -201,12 +201,12 @@ describe("navigate test", () => { }); it('should reload current tab by r', async () => { - let page = await Page.navigateTo(webdriver, server.url('/reload')); + const page = await Page.navigateTo(webdriver, server.url('/reload')); await page.scrollTo(500, 500); let before: number; await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; + const tab = (await browser.tabs.query({}))[0]; before = Number(new URL(tab.url).hash.split('#')[1]); assert.ok(before > 0); }); @@ -215,24 +215,24 @@ describe("navigate test", () => { let after; await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; + const tab = (await browser.tabs.query({}))[0]; after = Number(new URL(tab.url).hash.split('#')[1]); assert.ok(after > before); }); await eventually(async() => { - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); assert.strictEqual(await page.getScrollX(), 500); }); }); it('should reload current tab without cache by R', async () => { - let page = await Page.navigateTo(webdriver, server.url('/reload')); + const page = await Page.navigateTo(webdriver, server.url('/reload')); await page.scrollTo(500, 500); let before: number; await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; + const tab = (await browser.tabs.query({}))[0]; before = Number(new URL(tab.url).hash.split('#')[1]); assert.ok(before > 0); }); @@ -241,13 +241,13 @@ describe("navigate test", () => { let after; await eventually(async() => { - let tab = (await browser.tabs.query({}))[0]; + const tab = (await browser.tabs.query({}))[0]; after = Number(new URL(tab.url).hash.split('#')[1]); assert.ok(after > before); }); await eventually(async() => { - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); assert.strictEqual(await page.getScrollY(), 0); }); }); diff --git a/e2e/options.test.ts b/e2e/options.test.ts index f418dc3..91a3dde 100644 --- a/e2e/options.test.ts +++ b/e2e/options.test.ts @@ -9,7 +9,7 @@ import Page from './lib/Page'; import OptionPage from './lib/OptionPage'; describe("options page", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -35,15 +35,15 @@ describe("options page", () => { }); beforeEach(async() => { - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); it('saves current config on blur', async () => { - let page = await OptionPage.open(lanthan); - let jsonPage = await page.asJSONOptionPage(); + const page = await OptionPage.open(lanthan); + const jsonPage = await page.asJSONOptionPage(); await jsonPage.updateSettings(`{ "blacklist": [ "https://example.com" ] }`); let { settings } = await browser.storage.local.get('settings'); @@ -56,25 +56,25 @@ describe("options page", () => { assert.strictEqual(settings.source, 'json'); assert.strictEqual(settings.json, '{ "blacklist": [ "https://example.com" ] } '); - let message = await jsonPage.getErrorMessage(); + const message = await jsonPage.getErrorMessage(); assert.ok(message.startsWith('SyntaxError:')) }); it('updates keymaps without reloading', async () => { - let optionPage = await OptionPage.open(lanthan); - let jsonPage = await optionPage.asJSONOptionPage(); + const optionPage = await OptionPage.open(lanthan); + const jsonPage = await optionPage.asJSONOptionPage(); await jsonPage.updateSettings(`{ "keymaps": { "zz": { "type": "scroll.vertically", "count": 10 } } }`); await browser.tabs.create({ url: server.url(), active: false }); await new Promise((resolve) => setTimeout(resolve, 100)); - let handles = await webdriver.getAllWindowHandles(); + const handles = await webdriver.getAllWindowHandles(); await webdriver.switchTo().window(handles[1]); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('zz'); await eventually(async() => { - let y = await page.getScrollY(); + const y = await page.getScrollY(); assert.strictEqual(y, 640); }); }) diff --git a/e2e/options_form.test.ts b/e2e/options_form.test.ts index 75384a1..2121348 100644 --- a/e2e/options_form.test.ts +++ b/e2e/options_form.test.ts @@ -15,8 +15,8 @@ describe("options form page", () => { .build(); browser = lanthan.getWebExtBrowser(); - let tabs = await browser.tabs.query({}); - for (let tab of tabs.slice(1)) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } }); @@ -28,16 +28,16 @@ describe("options form page", () => { }); it('switch to form settings', async () => { - let page = await OptionPage.open(lanthan); + const page = await OptionPage.open(lanthan); await page.switchToForm(); - let { settings } = await browser.storage.local.get('settings'); + const { settings } = await browser.storage.local.get('settings'); assert.strictEqual(settings.source, 'form') }); it('add blacklist item', async () => { - let page = await OptionPage.open(lanthan); - let forms = await page.switchToForm(); + const page = await OptionPage.open(lanthan); + const forms = await page.switchToForm(); // assert default let settings = (await browser.storage.local.get('settings')).settings; @@ -63,8 +63,8 @@ describe("options form page", () => { }); it('add a partial blacklist item', async () => { - let page = await OptionPage.open(lanthan); - let forms = await page.switchToForm(); + const page = await OptionPage.open(lanthan); + const forms = await page.switchToForm(); // assert default let settings = (await browser.storage.local.get('settings')).settings; @@ -108,8 +108,8 @@ describe("options form page", () => { }); it('add search engines', async () => { - let page = await OptionPage.open(lanthan); - let forms = await page.switchToForm(); + const page = await OptionPage.open(lanthan); + const forms = await page.switchToForm(); // assert default let settings = (await browser.storage.local.get('settings')).settings; diff --git a/e2e/partial_blacklist.test.ts b/e2e/partial_blacklist.test.ts index 950bb39..cb66549 100644 --- a/e2e/partial_blacklist.test.ts +++ b/e2e/partial_blacklist.test.ts @@ -9,7 +9,7 @@ import Settings from '../src/shared/settings/Settings'; import SettingRepository from './lib/SettingRepository'; describe("partial blacklist test", () => { - let server = new TestServer().receiveContent('/*', + const server = new TestServer().receiveContent('/*', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -25,7 +25,7 @@ describe("partial blacklist test", () => { browser = lanthan.getWebExtBrowser(); await server.start(); - let url = server.url().replace('http://', ''); + const url = server.url().replace('http://', ''); await new SettingRepository(browser).saveJSON(Settings.fromJSON({ keymaps: { j: { type: 'scroll.vertically', count: 1 }, @@ -45,7 +45,7 @@ describe("partial blacklist test", () => { }); it('should disable keys in the partial blacklist', async () => { - let page = await Page.navigateTo(webdriver, server.url('/')); + const page = await Page.navigateTo(webdriver, server.url('/')); await page.sendKeys('j'); let scrollY = await page.getScrollY(); diff --git a/e2e/repeat.test.ts b/e2e/repeat.test.ts index b62272f..7c8b5e2 100644 --- a/e2e/repeat.test.ts +++ b/e2e/repeat.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("tab test", () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -32,11 +32,11 @@ describe("tab test", () => { it('repeats last command', async () => { let page = await Page.navigateTo(webdriver, server.url()); - let console = await page.showConsole(); + const console = await page.showConsole(); await console.execCommand(`tabopen ${server.url('/newtab')}`); await eventually(async() => { - let current = await browser.tabs.query({ url: `*://*/newtab` }); + const current = await browser.tabs.query({ url: `*://*/newtab` }); assert.strictEqual(current.length, 1); }); @@ -44,7 +44,7 @@ describe("tab test", () => { await page.sendKeys('.'); await eventually(async() => { - let current = await browser.tabs.query({ url: `*://*/newtab` }); + const current = await browser.tabs.query({ url: `*://*/newtab` }); assert.strictEqual(current.length, 2); }); }); @@ -53,13 +53,13 @@ describe("tab test", () => { for (let i = 1; i < 5; ++i) { await browser.tabs.create({ url: server.url('/#' + i) }); } - let before = await browser.tabs.query({}); + const before = await browser.tabs.query({}); let page = await Page.currentContext(webdriver); await page.sendKeys('d'); await eventually(async() => { - let current = await browser.tabs.query({}); + const current = await browser.tabs.query({}); assert.strictEqual(current.length, before.length - 1); }); @@ -68,7 +68,7 @@ describe("tab test", () => { await page.sendKeys('.'); await eventually(async() => { - let current = await browser.tabs.query({}); + const current = await browser.tabs.query({}); assert.strictEqual(current.length, before.length - 2); }); }); diff --git a/e2e/repeat_n_times.test.ts b/e2e/repeat_n_times.test.ts index d28f3c9..a646112 100644 --- a/e2e/repeat_n_times.test.ts +++ b/e2e/repeat_n_times.test.ts @@ -8,7 +8,7 @@ import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; describe("tab test", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -35,25 +35,25 @@ describe("tab test", () => { }); it('repeats scroll 3-times', async () => { - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('3', 'j'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 64 * 3); }); it('repeats tab deletion 3-times', async () => { - let win = await browser.windows.create({ url: server.url('/#0') }); + const win = await browser.windows.create({ url: server.url('/#0') }); for (let i = 1; i < 5; ++i) { await browser.tabs.create({ url: server.url('/#' + i), windowId: win.id }); await webdriver.navigate().to(server.url('/#' + i)); } - let page = await Page.navigateTo(webdriver, server.url()); + const page = await Page.navigateTo(webdriver, server.url()); await page.sendKeys('3', 'd'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, 2); }); }); diff --git a/e2e/scroll.test.ts b/e2e/scroll.test.ts index 5145265..9b39a2e 100644 --- a/e2e/scroll.test.ts +++ b/e2e/scroll.test.ts @@ -7,7 +7,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; describe("scroll test", () => { - let server = new TestServer().receiveContent('/', + const server = new TestServer().receiveContent('/', `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`, ); let lanthan: Lanthan; @@ -39,7 +39,7 @@ describe("scroll test", () => { it('scrolls up by j', async () => { await page.sendKeys('j'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 64); }); @@ -47,7 +47,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 200)); await page.sendKeys('k'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 136); }); @@ -55,7 +55,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(100, 100)); await page.sendKeys('h'); - let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; + const pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; assert.strictEqual(pageXOffset, 36); }); @@ -63,7 +63,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(100, 100)); await page.sendKeys('l'); - let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; + const pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; assert.strictEqual(pageXOffset, 164); }); @@ -71,7 +71,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 100)); await page.sendKeys('g', 'g'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 0); }); @@ -79,7 +79,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 100)); await page.sendKeys(Key.SHIFT, 'g'); - let scrollY = await page.getScrollY(); + const scrollY = await page.getScrollY(); assert.ok(scrollY > 5000); }); @@ -87,7 +87,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 100)); await page.sendKeys(Key.SHIFT, '0'); - let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; + const pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; assert.ok(pageXOffset === 0); }); @@ -95,7 +95,7 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 100)); await page.sendKeys(Key.SHIFT, '$'); - let pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; + const pageXOffset = await webdriver.executeScript(() => window.pageXOffset) as number; assert.ok(pageXOffset > 5000); }); @@ -103,8 +103,8 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 1000)); await page.sendKeys(Key.CONTROL, 'u'); - let pageHeight = await page.pageHeight(); - let scrollY = await page.getScrollY(); + const pageHeight = await page.pageHeight(); + const scrollY = await page.getScrollY(); assert.ok(Math.abs(scrollY - (1000 - Math.floor(pageHeight / 2))) < 5); }); @@ -112,8 +112,8 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 1000)); await page.sendKeys(Key.CONTROL, 'd'); - let pageHeight = await page.pageHeight(); - let scrollY = await page.getScrollY(); + const pageHeight = await page.pageHeight(); + const scrollY = await page.getScrollY(); assert.ok(Math.abs(scrollY - (1000 + Math.floor(pageHeight / 2))) < 5); }); @@ -121,8 +121,8 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 1000)); await page.sendKeys(Key.CONTROL, 'b'); - let pageHeight = await page.pageHeight(); - let scrollY = await page.getScrollY(); + const pageHeight = await page.pageHeight(); + const scrollY = await page.getScrollY(); assert.ok(Math.abs(scrollY - (1000 - pageHeight)) < 5); }); @@ -130,8 +130,8 @@ describe("scroll test", () => { await webdriver.executeScript(() => window.scrollTo(0, 1000)); await page.sendKeys(Key.CONTROL, 'f'); - let pageHeight = await page.pageHeight(); - let scrollY = await page.getScrollY(); + const pageHeight = await page.pageHeight(); + const scrollY = await page.getScrollY(); assert.ok(Math.abs(scrollY - (1000 + pageHeight)) < 5); }); }); diff --git a/e2e/tab.test.ts b/e2e/tab.test.ts index 1a5dd5c..6a8e815 100644 --- a/e2e/tab.test.ts +++ b/e2e/tab.test.ts @@ -8,7 +8,7 @@ import { WebDriver, Key } from 'selenium-webdriver'; import Page from './lib/Page'; describe("tab test", () => { - let server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent('/*', 'ok'); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; @@ -48,11 +48,11 @@ describe("tab test", () => { it('deletes tab and selects right by d', async () => { await browser.tabs.update(tabs[3].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('d'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length - 1); assert.strictEqual(current[3].active, true); assert.strictEqual(current[3].id, tabs[4].id); @@ -61,11 +61,11 @@ describe("tab test", () => { it('deletes tab and selects left by D', async () => { await browser.tabs.update(tabs[3].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'D'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length - 1); assert.strictEqual(current[2].active, true); assert.strictEqual(current[2].id, tabs[2].id); @@ -74,20 +74,20 @@ describe("tab test", () => { it('deletes all tabs to the right by x$', async () => { await browser.tabs.update(tabs[1].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('x', '$'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, 2); }); it('duplicates tab by zd', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('z', 'd'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); current.sort((t1: any, t2: any) => t1.index - t2.index); assert.strictEqual(current.length, tabs.length + 1); assert.strictEqual(current[0].url, current[1].url); @@ -96,64 +96,64 @@ describe("tab test", () => { it('makes pinned by zp', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('z', 'p'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[0].pinned, true); }); it('selects previous tab by K', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'K'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[1].active, true); }); it('selects previous tab by K rotatory', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'K'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[current.length - 1].active, true) }); it('selects next tab by J', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'J'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[3].active, true); }); it('selects previous tab by J rotatory', async () => { await browser.tabs.update(tabs[tabs.length - 1].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.SHIFT, 'J'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[0].active, true) }); it('selects first tab by g0', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('g', '0'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[0].active, true) }); it('selects last tab by g$', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('g', '$'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[current.length - 1].active, true) }); @@ -161,10 +161,10 @@ describe("tab test", () => { await browser.tabs.update(tabs[1].id, { active: true }); await browser.tabs.update(tabs[4].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys(Key.CONTROL, '6'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current[1].active, true) }); @@ -172,38 +172,38 @@ describe("tab test", () => { // This might be a bug in Firefox. it.skip('reopen tab by u', async () => { await browser.tabs.remove(tabs[1].id); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('u'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length); }); it('does not delete pinned tab by d', async () => { await browser.tabs.update(tabs[0].id, { active: true, pinned: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('d'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length); }); it('deletes pinned tab by !d', async () => { await browser.tabs.update(tabs[0].id, { active: true, pinned: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('!', 'd'); - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length - 1); }); it('opens view-source by gf', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let page = await Page.currentContext(webdriver); + const page = await Page.currentContext(webdriver); await page.sendKeys('g', 'f'); await eventually(async() => { - let current = await browser.tabs.query({ windowId: win.id }); + const current = await browser.tabs.query({ windowId: win.id }); assert.strictEqual(current.length, tabs.length + 1); assert.strictEqual(current[current.length - 1].url, `view-source:${server.url('/#0')}`); }); diff --git a/e2e/zoom.test.ts b/e2e/zoom.test.ts index af5cc68..d089097 100644 --- a/e2e/zoom.test.ts +++ b/e2e/zoom.test.ts @@ -33,21 +33,21 @@ describe("zoom test", () => { }); it('should zoom in by zi', async () => { - let before = await browser.tabs.getZoom(tab.id); + const before = await browser.tabs.getZoom(tab.id); await page.sendKeys('zi'); await eventually(async() => { - let actual = await browser.tabs.getZoom(tab.id); + const actual = await browser.tabs.getZoom(tab.id); assert.ok(before < actual); }); }); it('should zoom out by zo', async () => { - let before = await browser.tabs.getZoom(tab.id); + const before = await browser.tabs.getZoom(tab.id); await page.sendKeys('zo'); await eventually(async() => { - let actual = await browser.tabs.getZoom(tab.id); + const actual = await browser.tabs.getZoom(tab.id); assert.ok(before > actual); }); }); @@ -57,7 +57,7 @@ describe("zoom test", () => { await page.sendKeys('zz'); await eventually(async() => { - let actual = await browser.tabs.getZoom(tab.id); + const actual = await browser.tabs.getZoom(tab.id); assert.strictEqual(actual, 1); }); }); diff --git a/test/background/infrastructures/MemoryStorage.test.ts b/test/background/infrastructures/MemoryStorage.test.ts index 95d3780..ccdf9f0 100644 --- a/test/background/infrastructures/MemoryStorage.test.ts +++ b/test/background/infrastructures/MemoryStorage.test.ts @@ -2,7 +2,7 @@ import MemoryStorage from 'background/infrastructures/MemoryStorage'; describe("background/infrastructures/memory-storage", () => { it('stores values', () => { - let cache = new MemoryStorage(); + const cache = new MemoryStorage(); cache.set('number', 123); expect(cache.get('number')).to.equal(123); @@ -14,7 +14,7 @@ describe("background/infrastructures/memory-storage", () => { }); it('returns undefined if no keys', () => { - let cache = new MemoryStorage(); + const cache = new MemoryStorage(); expect(cache.get('no-keys')).to.be.undefined; }) @@ -23,22 +23,22 @@ describe("background/infrastructures/memory-storage", () => { cache.set('red', 'apple'); cache = new MemoryStorage(); - let got = cache.get('red'); + const got = cache.get('red'); expect(got).to.equal('apple'); }); it('stored cloned objects', () => { - let cache = new MemoryStorage(); - let recipe = { sugar: '300g' }; + const cache = new MemoryStorage(); + const recipe = { sugar: '300g' }; cache.set('recipe', recipe); recipe.salt = '20g' - let got = cache.get('recipe', recipe); + const got = cache.get('recipe', recipe); expect(got).to.deep.equal({ sugar: '300g' }); }); it('throws an error with unserializable objects', () => { - let cache = new MemoryStorage(); + const cache = new MemoryStorage(); expect(() => cache.set('fn', setTimeout)).to.throw(); }) }); diff --git a/test/background/repositories/Mark.test.ts b/test/background/repositories/Mark.test.ts index 167e512..625f11d 100644 --- a/test/background/repositories/Mark.test.ts +++ b/test/background/repositories/Mark.test.ts @@ -9,7 +9,7 @@ describe('background/repositories/mark', () => { }); it('get and set', async() => { - let mark = { tabId: 1, url: 'http://example.com', x: 10, y: 30 }; + const mark = { tabId: 1, url: 'http://example.com', x: 10, y: 30 }; repository.setMark('A', mark); diff --git a/test/background/usecases/NavigateUseCase.test.ts b/test/background/usecases/NavigateUseCase.test.ts index ecbf888..48a1c5b 100644 --- a/test/background/usecases/NavigateUseCase.test.ts +++ b/test/background/usecases/NavigateUseCase.test.ts @@ -16,10 +16,10 @@ describe('NavigateUseCase', () => { describe('#openParent()', async () => { it('opens parent directory of file', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/fruits/yellow/banana' })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com/fruits/yellow/'); await sut.openParent(); @@ -28,10 +28,10 @@ describe('NavigateUseCase', () => { }); it('opens parent directory of directory', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/fruits/yellow/' })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com/fruits/'); await sut.openParent(); @@ -40,10 +40,10 @@ describe('NavigateUseCase', () => { }); it('removes hash', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/#top' })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com/'); await sut.openParent(); @@ -52,10 +52,10 @@ describe('NavigateUseCase', () => { }); it('removes search query', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/search?q=apple' })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com/search'); await sut.openParent(); @@ -66,12 +66,12 @@ describe('NavigateUseCase', () => { describe('#openRoot()', () => { it('opens root direectory', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/seach?q=apple', })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com'); await sut.openRoot(); diff --git a/test/background/usecases/filters.test.ts b/test/background/usecases/filters.test.ts index bdfb0be..90541ff 100644 --- a/test/background/usecases/filters.test.ts +++ b/test/background/usecases/filters.test.ts @@ -3,15 +3,15 @@ import * as filters from 'background/usecases/filters'; describe("background/usecases/filters", () => { describe('filterHttp', () => { it('filters http URLs duplicates to https hosts', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/foo' }, { url: 'https://i-beam.org/bar' }, { url: 'http://i-beam.net/hoge' }, { url: 'http://i-beam.net/fuga' }, ]; - let filtered = filters.filterHttp(pages); + const filtered = filters.filterHttp(pages); - let urls = filtered.map(x => x.url); + const urls = filtered.map(x => x.url); expect(urls).to.deep.equal([ 'https://i-beam.org/bar', 'http://i-beam.net/hoge', 'http://i-beam.net/fuga' ]); @@ -20,12 +20,12 @@ describe("background/usecases/filters", () => { describe('filterBlankTitle', () => { it('filters blank titles', () => { - let pages = [ + const pages = [ { title: 'hello' }, { title: '' }, {}, ]; - let filtered = filters.filterBlankTitle(pages); + const filtered = filters.filterBlankTitle(pages); expect(filtered).to.deep.equal([{ title: 'hello' }]); }); @@ -33,15 +33,15 @@ describe("background/usecases/filters", () => { describe('filterByTailingSlash', () => { it('filters duplicated pathname on tailing slash', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/content' }, { url: 'http://i-beam.org/content/' }, { url: 'http://i-beam.org/search' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByTailingSlash(pages); + const filtered = filters.filterByTailingSlash(pages); - let urls = filtered.map(x => x.url); + const urls = filtered.map(x => x.url); expect(urls).to.deep.equal([ 'http://i-beam.org/content', 'http://i-beam.org/search', @@ -52,7 +52,7 @@ describe("background/usecases/filters", () => { describe('filterByPathname', () => { it('remains items less than minimam length', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.org/search?q=apple_banana' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, @@ -60,12 +60,12 @@ describe("background/usecases/filters", () => { { url: 'http://i-beam.org/request?q=apple_banana' }, { url: 'http://i-beam.org/request?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByPathname(pages, 10); + const filtered = filters.filterByPathname(pages, 10); expect(filtered).to.have.lengthOf(6); }); it('filters by length of pathname', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.org/search?q=apple_banana' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, @@ -73,7 +73,7 @@ describe("background/usecases/filters", () => { { url: 'http://i-beam.net/search?q=apple_banana' }, { url: 'http://i-beam.net/search?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByPathname(pages, 0); + const filtered = filters.filterByPathname(pages, 0); expect(filtered).to.deep.equal([ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.net/search?q=apple' }, @@ -83,7 +83,7 @@ describe("background/usecases/filters", () => { describe('filterByOrigin', () => { it('remains items less than minimam length', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.org/search?q=apple_banana' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, @@ -91,12 +91,12 @@ describe("background/usecases/filters", () => { { url: 'http://i-beam.org/request?q=apple_banana' }, { url: 'http://i-beam.org/request?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByOrigin(pages, 10); + const filtered = filters.filterByOrigin(pages, 10); expect(filtered).to.have.lengthOf(6); }); it('filters by length of pathname', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.org/search?q=apple_banana' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, @@ -104,7 +104,7 @@ describe("background/usecases/filters", () => { { url: 'http://i-beam.org/request?q=apple_banana' }, { url: 'http://i-beam.org/request?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByOrigin(pages, 0); + const filtered = filters.filterByOrigin(pages, 0); expect(filtered).to.deep.equal([ { url: 'http://i-beam.org/search?q=apple' }, ]); diff --git a/test/background/usecases/parsers.test.ts b/test/background/usecases/parsers.test.ts index f3a64eb..d08de0d 100644 --- a/test/background/usecases/parsers.test.ts +++ b/test/background/usecases/parsers.test.ts @@ -3,13 +3,13 @@ import * as parsers from 'background/usecases/parsers'; describe("shared/commands/parsers", () => { describe("#parsers.parseSetOption", () => { it('parse set string', () => { - let [key, value] = parsers.parseSetOption('hintchars=abcdefgh'); + const [key, value] = parsers.parseSetOption('hintchars=abcdefgh'); expect(key).to.equal('hintchars'); expect(value).to.equal('abcdefgh'); }); it('parse set empty string', () => { - let [key, value] = parsers.parseSetOption('hintchars='); + const [key, value] = parsers.parseSetOption('hintchars='); expect(key).to.equal('hintchars'); expect(value).to.equal(''); }); diff --git a/test/console/actions/console.test.ts b/test/console/actions/console.test.ts index e45d008..583c878 100644 --- a/test/console/actions/console.test.ts +++ b/test/console/actions/console.test.ts @@ -4,13 +4,13 @@ import * as consoleActions from 'console/actions/console'; describe("console actions", () => { describe('hide', () => { it('create CONSOLE_HIDE action', () => { - let action = consoleActions.hide(); + const action = consoleActions.hide(); expect(action.type).to.equal(actions.CONSOLE_HIDE); }); }); describe("showCommand", () => { it('create CONSOLE_SHOW_COMMAND action', () => { - let action = consoleActions.showCommand('hello'); + const action = consoleActions.showCommand('hello'); expect(action.type).to.equal(actions.CONSOLE_SHOW_COMMAND); expect(action.text).to.equal('hello'); }); @@ -18,14 +18,14 @@ describe("console actions", () => { describe("showFind", () => { it('create CONSOLE_SHOW_FIND action', () => { - let action = consoleActions.showFind(); + const action = consoleActions.showFind(); expect(action.type).to.equal(actions.CONSOLE_SHOW_FIND); }); }); describe("showError", () => { it('create CONSOLE_SHOW_ERROR action', () => { - let action = consoleActions.showError('an error'); + const action = consoleActions.showError('an error'); expect(action.type).to.equal(actions.CONSOLE_SHOW_ERROR); expect(action.text).to.equal('an error'); }); @@ -33,7 +33,7 @@ describe("console actions", () => { describe("showInfo", () => { it('create CONSOLE_SHOW_INFO action', () => { - let action = consoleActions.showInfo('an info'); + const action = consoleActions.showInfo('an info'); expect(action.type).to.equal(actions.CONSOLE_SHOW_INFO); expect(action.text).to.equal('an info'); }); @@ -41,14 +41,14 @@ describe("console actions", () => { describe("hideCommand", () => { it('create CONSOLE_HIDE_COMMAND action', () => { - let action = consoleActions.hideCommand(); + const action = consoleActions.hideCommand(); expect(action.type).to.equal(actions.CONSOLE_HIDE_COMMAND); }); }); describe('setConsoleText', () => { it('create CONSOLE_SET_CONSOLE_TEXT action', () => { - let action = consoleActions.setConsoleText('hello world'); + const action = consoleActions.setConsoleText('hello world'); expect(action.type).to.equal(actions.CONSOLE_SET_CONSOLE_TEXT); expect(action.consoleText).to.equal('hello world'); }); @@ -56,14 +56,14 @@ describe("console actions", () => { describe("completionPrev", () => { it('create CONSOLE_COMPLETION_PREV action', () => { - let action = consoleActions.completionPrev(); + const action = consoleActions.completionPrev(); expect(action.type).to.equal(actions.CONSOLE_COMPLETION_PREV); }); }); describe("completionNext", () => { it('create CONSOLE_COMPLETION_NEXT action', () => { - let action = consoleActions.completionNext(); + const action = consoleActions.completionNext(); expect(action.type).to.equal(actions.CONSOLE_COMPLETION_NEXT); }); }); diff --git a/test/console/components/console/Completion.test.tsx b/test/console/components/console/Completion.test.tsx index 16bf11a..a271d77 100644 --- a/test/console/components/console/Completion.test.tsx +++ b/test/console/components/console/Completion.test.tsx @@ -3,7 +3,7 @@ import Completion from 'console/components/console/Completion' import ReactTestRenderer from 'react-test-renderer'; describe("console/components/console/completion", () => { - let completions = [{ + const completions = [{ name: "Fruit", items: [{ caption: "apple" }, { caption: "banana" }, { caption: "cherry" }], }, { @@ -12,14 +12,14 @@ describe("console/components/console/completion", () => { }]; it('renders Completion component', () => { - let root = ReactTestRenderer.create(<Completion + const root = ReactTestRenderer.create(<Completion completions={completions} size={30} />).root; expect(root.children).to.have.lengthOf(1); - let children = root.children[0].children; + const children = root.children[0].children; expect(children).to.have.lengthOf(8); expect(children[0].props.title).to.equal('Fruit'); expect(children[1].props.caption).to.equal('apple'); @@ -32,25 +32,25 @@ describe("console/components/console/completion", () => { }); it('highlight current item', () => { - let root = ReactTestRenderer.create(<Completion + const root = ReactTestRenderer.create(<Completion completions={completions} size={30} select={3} />).root; - let children = root.children[0].children; + const children = root.children[0].children; expect(children[5].props.highlight).to.be.true; }); it('does not highlight any items', () => { - let root = ReactTestRenderer.create(<Completion + const root = ReactTestRenderer.create(<Completion completions={completions} size={30} select={-1} />).root; - let children = root.children[0].children; - for (let li of children[0].children) { + const children = root.children[0].children; + for (const li of children[0].children) { expect(li.props.highlight).not.to.be.ok; } }); @@ -79,13 +79,13 @@ describe("console/components/console/completion", () => { }) it('scrolls up to down with select', () => { - let component = ReactTestRenderer.create(<Completion + const component = ReactTestRenderer.create(<Completion completions={completions} size={3} select={1} />); - let instance = component.getInstance(); - let root = component.root; + const instance = component.getInstance(); + const root = component.root; let children = root.children[0].children; expect(children).to.have.lengthOf(3); @@ -121,13 +121,13 @@ describe("console/components/console/completion", () => { }); it('scrolls down to up with select', () => { - let component = ReactTestRenderer.create(<Completion + const component = ReactTestRenderer.create(<Completion completions={completions} size={3} select={5} />); - let root = component.root; - let instance = component.getInstance(); + const root = component.root; + const instance = component.getInstance(); let children = root.children[0].children; expect(children).to.have.lengthOf(3); diff --git a/test/console/reducers/console.test.ts b/test/console/reducers/console.test.ts index 47e7daf..038e712 100644 --- a/test/console/reducers/console.test.ts +++ b/test/console/reducers/console.test.ts @@ -3,7 +3,7 @@ import reducer from 'console/reducers'; describe("console reducer", () => { it('return the initial state', () => { - let state = reducer(undefined, {}); + const state = reducer(undefined, {}); expect(state).to.have.property('mode', ''); expect(state).to.have.property('messageText', ''); expect(state).to.have.property('consoleText', ''); @@ -12,34 +12,34 @@ describe("console reducer", () => { }); it('return next state for CONSOLE_HIDE', () => { - let action = { type: actions.CONSOLE_HIDE }; - let state = reducer({ mode: 'error' }, action); + const action = { type: actions.CONSOLE_HIDE }; + const state = reducer({ mode: 'error' }, action); expect(state).to.have.property('mode', ''); }) it('return next state for CONSOLE_SHOW_COMMAND', () => { - let action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' }; - let state = reducer({}, action); + const action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' }; + const state = reducer({}, action); expect(state).to.have.property('mode', 'command'); expect(state).to.have.property('consoleText', 'open '); }); it('return next state for CONSOLE_SHOW_INFO', () => { - let action = { type: actions.CONSOLE_SHOW_INFO, text: 'an info' }; - let state = reducer({}, action); + const action = { type: actions.CONSOLE_SHOW_INFO, text: 'an info' }; + const state = reducer({}, action); expect(state).to.have.property('mode', 'info'); expect(state).to.have.property('messageText', 'an info'); }); it('return next state for CONSOLE_SHOW_ERROR', () => { - let action = { type: actions.CONSOLE_SHOW_ERROR, text: 'an error' }; - let state = reducer({}, action); + const action = { type: actions.CONSOLE_SHOW_ERROR, text: 'an error' }; + const state = reducer({}, action); expect(state).to.have.property('mode', 'error'); expect(state).to.have.property('messageText', 'an error'); }); it('return next state for CONSOLE_HIDE_COMMAND', () => { - let action = { type: actions.CONSOLE_HIDE_COMMAND }; + const action = { type: actions.CONSOLE_HIDE_COMMAND }; let state = reducer({ mode: 'command' }, action); expect(state).to.have.property('mode', ''); @@ -48,11 +48,11 @@ describe("console reducer", () => { }); it('return next state for CONSOLE_SET_CONSOLE_TEXT', () => { - let action = { + const action = { type: actions.CONSOLE_SET_CONSOLE_TEXT, consoleText: 'hello world' } - let state = reducer({}, action) + const state = reducer({}, action) expect(state).to.have.property('consoleText', 'hello world'); }); @@ -62,7 +62,7 @@ describe("console reducer", () => { select: 0, completions: [], } - let action = { + const action = { type: actions.CONSOLE_SET_COMPLETIONS, completions: [{ name: 'Apple', @@ -78,7 +78,7 @@ describe("console reducer", () => { }); it ('return next state for CONSOLE_COMPLETION_NEXT', () => { - let action = { type: actions.CONSOLE_COMPLETION_NEXT }; + const action = { type: actions.CONSOLE_COMPLETION_NEXT }; let state = { select: -1, completions: [{ @@ -104,7 +104,7 @@ describe("console reducer", () => { }); it ('return next state for CONSOLE_COMPLETION_PREV', () => { - let action = { type: actions.CONSOLE_COMPLETION_PREV }; + const action = { type: actions.CONSOLE_COMPLETION_PREV }; let state = { select: -1, completions: [{ diff --git a/test/content/InputDriver.test.ts b/test/content/InputDriver.test.ts index 441d107..367ec1d 100644 --- a/test/content/InputDriver.test.ts +++ b/test/content/InputDriver.test.ts @@ -50,7 +50,7 @@ describe('InputDriver', () => { return true; }); - let events = [ + const events = [ new KeyboardEvent('keydown', { key: 'a' }), new KeyboardEvent('keydown', { key: 'b' }), new KeyboardEvent('keypress', { key: 'a' }), @@ -58,7 +58,7 @@ describe('InputDriver', () => { new KeyboardEvent('keypress', { key: 'b' }), new KeyboardEvent('keyup', { key: 'b' }), ]; - for (let e of events) { + for (const e of events) { target.dispatchEvent(e); } @@ -102,8 +102,8 @@ describe('InputDriver', () => { it('ignores events from input elements', () => { ['input', 'textarea', 'select'].forEach((name) => { - let input = window.document.createElement(name); - let driver = new InputDriver(input); + const input = window.document.createElement(name); + const driver = new InputDriver(input); driver.onKey((key: Key): boolean => { expect.fail(); return false; @@ -113,8 +113,8 @@ describe('InputDriver', () => { }); it('ignores events from contenteditable elements', () => { - let div = window.document.createElement('div'); - let driver = new InputDriver(div); + const div = window.document.createElement('div'); + const driver = new InputDriver(div); driver.onKey((_key: Key): boolean => { expect.fail(); return false; @@ -130,7 +130,7 @@ describe('InputDriver', () => { describe("#keyFromKeyboardEvent", () => { it('returns from keyboard input Ctrl+X', () => { - let k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { + const k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { key: 'x', shiftKey: false, ctrlKey: true, altKey: false, metaKey: true, })); expect(k.key).to.equal('x'); @@ -141,7 +141,7 @@ describe("#keyFromKeyboardEvent", () => { }); it('returns from keyboard input Shift+Esc', () => { - let k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { + const k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { key: 'Escape', shiftKey: true, ctrlKey: false, altKey: false, metaKey: true })); expect(k.key).to.equal('Esc'); @@ -153,7 +153,7 @@ describe("#keyFromKeyboardEvent", () => { it('returns from keyboard input Ctrl+$', () => { // $ required shift pressing on most keyboards - let k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { + const k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { key: '$', shiftKey: true, ctrlKey: true, altKey: false, metaKey: false })); expect(k.key).to.equal('$'); @@ -164,7 +164,7 @@ describe("#keyFromKeyboardEvent", () => { }); it('returns from keyboard input Crtl+Space', () => { - let k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { + const k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { key: ' ', shiftKey: false, ctrlKey: true, altKey: false, metaKey: false })); expect(k.key).to.equal('Space'); diff --git a/test/content/domains/KeySequence.test.ts b/test/content/domains/KeySequence.test.ts index bc16189..5df5217 100644 --- a/test/content/domains/KeySequence.test.ts +++ b/test/content/domains/KeySequence.test.ts @@ -5,7 +5,7 @@ import Key from "../../../src/shared/settings/Key"; describe("KeySequence", () => { describe('#push', () => { it('append a key to the sequence', () => { - let seq = new KeySequence([]); + const seq = new KeySequence([]); seq.push(Key.fromMapKey('g')); seq.push(Key.fromMapKey('<S-U>')); @@ -17,7 +17,7 @@ describe("KeySequence", () => { describe('#startsWith', () => { it('returns true if the key sequence starts with param', () => { - let seq = new KeySequence([ + const seq = new KeySequence([ Key.fromMapKey('g'), Key.fromMapKey('<S-U>'), ]); @@ -39,7 +39,7 @@ describe("KeySequence", () => { }); it('returns true if the empty sequence starts with an empty sequence', () => { - let seq = new KeySequence([]); + const seq = new KeySequence([]); expect(seq.startsWith(new KeySequence([]))).to.be.true; expect(seq.startsWith(new KeySequence([ @@ -102,7 +102,7 @@ describe("KeySequence", () => { describe('#trimNumericPrefix', () => { it('removes numeric prefix', () => { - let seq = new KeySequence([ + const seq = new KeySequence([ new Key({ key: '1' }), new Key({ key: '0' }) , new Key({ key: 'g' }), new Key({ key: 'g' }) , new Key({ key: '3' }) , ]).trimNumericPrefix(); @@ -110,14 +110,14 @@ describe("KeySequence", () => { }); it('returns empty if keys contains only digis', () => { - let seq = new KeySequence([ + const seq = new KeySequence([ new Key({ key: '1' }), new Key({ key: '0' }) , ]).trimNumericPrefix(); expect(seq.trimNumericPrefix().keys).to.be.empty; }); it('returns itself if no numeric prefix', () => { - let seq = new KeySequence([ + const seq = new KeySequence([ new Key({ key: 'g' }), new Key({ key: 'g' }) , new Key({ key: '3' }) , ]).trimNumericPrefix(); @@ -144,14 +144,14 @@ describe("KeySequence", () => { describe('#fromMapKeys', () => { it('returns mapped keys for Shift+Esc', () => { - let keys = KeySequence.fromMapKeys('<S-Esc>').keys; + const keys = KeySequence.fromMapKeys('<S-Esc>').keys; expect(keys).to.have.lengthOf(1); expect(keys[0].key).to.equal('Esc'); expect(keys[0].shift).to.be.true; }); 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; + const keys = KeySequence.fromMapKeys('a<C-B><A-C>d<M-e>').keys; expect(keys).to.have.lengthOf(5); expect(keys[0].key).to.equal('a'); expect(keys[1].ctrl).to.be.true; diff --git a/test/content/presenters/Hint.test.ts b/test/content/presenters/Hint.test.ts index 7994788..708ddaa 100644 --- a/test/content/presenters/Hint.test.ts +++ b/test/content/presenters/Hint.test.ts @@ -11,43 +11,43 @@ describe('Hint', () => { describe('#constructor', () => { it('creates a hint element with tag name', () => { - let link = document.getElementById('test-link'); - let hint = new Hint(link, 'abc'); + const link = document.getElementById('test-link'); + const hint = new Hint(link, 'abc'); - let elem = document.querySelector('.vimvixen-hint'); + const elem = document.querySelector('.vimvixen-hint'); expect(elem.textContent.trim()).to.be.equal('abc'); }); }); describe('#show', () => { it('shows an element', () => { - let link = document.getElementById('test-link'); - let hint = new Hint(link, 'abc'); + const link = document.getElementById('test-link'); + const hint = new Hint(link, 'abc'); hint.hide(); hint.show(); - let elem = document.querySelector('.vimvixen-hint') as HTMLElement; + const elem = document.querySelector('.vimvixen-hint') as HTMLElement; expect(elem.style.display).to.not.equal('none'); }); }); describe('#hide', () => { it('hides an element', () => { - let link = document.getElementById('test-link') as HTMLElement; - let hint = new Hint(link, 'abc'); + const link = document.getElementById('test-link') as HTMLElement; + const hint = new Hint(link, 'abc'); hint.hide(); - let elem = document.querySelector('.vimvixen-hint') as HTMLElement; + const elem = document.querySelector('.vimvixen-hint') as HTMLElement; expect(elem.style.display).to.equal('none'); }); }); describe('#remove', () => { it('removes an element', () => { - let link = document.getElementById('test-link'); - let hint = new Hint(link, 'abc'); + const link = document.getElementById('test-link'); + const hint = new Hint(link, 'abc'); - let elem = document.querySelector('.vimvixen-hint'); + const elem = document.querySelector('.vimvixen-hint'); expect(elem.parentElement).to.not.be.null; hint.remove(); expect(elem.parentElement).to.be.null; @@ -66,8 +66,8 @@ describe('LinkHint', () => { describe('#getLink()', () => { it('returns value of "href" attribute', () => { - let link = document.getElementById('test-link1') as HTMLAnchorElement; - let hint = new LinkHint(link, 'abc'); + const link = document.getElementById('test-link1') as HTMLAnchorElement; + const hint = new LinkHint(link, 'abc'); expect(hint.getLink()).to.equal('https://google.com/'); }); @@ -89,8 +89,8 @@ describe('LinkHint', () => { describe('#click()', () => { it('clicks a element', (done) => { - let link = document.getElementById('test-link3') as HTMLAnchorElement; - let hint = new LinkHint(link, 'abc'); + const link = document.getElementById('test-link3') as HTMLAnchorElement; + const hint = new LinkHint(link, 'abc'); link.onclick = () => { done() }; hint.click(); @@ -106,8 +106,8 @@ describe('InputHint', () => { }); it('focuses to the input', () => { - let input = document.getElementById('test-input') as HTMLInputElement; - let hint = new InputHint(input, 'abc'); + const input = document.getElementById('test-input') as HTMLInputElement; + const hint = new InputHint(input, 'abc'); hint.activate(); expect(document.activeElement).to.equal(input); @@ -120,8 +120,8 @@ describe('InputHint', () => { }); it('checks and focuses to the input', () => { - let input = document.getElementById('test-input') as HTMLInputElement; - let hint = new InputHint(input, 'abc'); + const input = document.getElementById('test-input') as HTMLInputElement; + const hint = new InputHint(input, 'abc'); hint.activate(); expect(input.checked).to.be.true; @@ -133,8 +133,8 @@ describe('InputHint', () => { }); it('focuses to the textarea', () => { - let textarea = document.getElementById('test-textarea') as HTMLTextAreaElement; - let hint = new InputHint(textarea, 'abc'); + const textarea = document.getElementById('test-textarea') as HTMLTextAreaElement; + const hint = new InputHint(textarea, 'abc'); hint.activate(); expect(document.activeElement).to.equal(textarea); @@ -147,10 +147,10 @@ describe('InputHint', () => { }); it('clicks the button', (done) => { - let button = document.getElementById('test-button') as HTMLButtonElement; + const button = document.getElementById('test-button') as HTMLButtonElement; button.onclick = () => { done() }; - let hint = new InputHint(button, 'abc'); + const hint = new InputHint(button, 'abc'); hint.activate(); }); }); diff --git a/test/content/repositories/AddonEnabledRepository.test.ts b/test/content/repositories/AddonEnabledRepository.test.ts index 3cea897..7edd50e 100644 --- a/test/content/repositories/AddonEnabledRepository.test.ts +++ b/test/content/repositories/AddonEnabledRepository.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; describe('AddonEnabledRepositoryImpl', () => { it('updates and gets current value', () => { - let sut = new AddonEnabledRepositoryImpl(); + const sut = new AddonEnabledRepositoryImpl(); sut.set(true); expect(sut.get()).to.be.true; diff --git a/test/content/repositories/FindRepository.test.ts b/test/content/repositories/FindRepository.test.ts index dcb2dff..0e50b0a 100644 --- a/test/content/repositories/FindRepository.test.ts +++ b/test/content/repositories/FindRepository.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; describe('FindRepositoryImpl', () => { it('updates and gets last keyword', () => { - let sut = new FindRepositoryImpl(); + const sut = new FindRepositoryImpl(); expect(sut.getLastKeyword()).to.be.null; diff --git a/test/content/repositories/FollowMasterRepository.test.ts b/test/content/repositories/FollowMasterRepository.test.ts index 8c3f34e..3eb172f 100644 --- a/test/content/repositories/FollowMasterRepository.test.ts +++ b/test/content/repositories/FollowMasterRepository.test.ts @@ -25,7 +25,7 @@ describe('FollowMasterRepositoryImpl', () => { describe('#getTagsByPrefix', () => { it('gets tags matched by prefix', () => { - for (let tag of ['a', 'aa', 'ab', 'b', 'ba', 'bb']) { + for (const tag of ['a', 'aa', 'ab', 'b', 'ba', 'bb']) { sut.addTag(tag); } expect(sut.getTagsByPrefix('a')).to.deep.equal(['a', 'aa', 'ab']); diff --git a/test/content/repositories/MarkRepository.test.ts b/test/content/repositories/MarkRepository.test.ts index 7fced5f..6ddd38d 100644 --- a/test/content/repositories/MarkRepository.test.ts +++ b/test/content/repositories/MarkRepository.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; describe('MarkRepositoryImpl', () => { it('save and load marks', () => { - let sut = new MarkRepositoryImpl(); + const sut = new MarkRepositoryImpl(); sut.set('a', { x: 10, y: 20 }); expect(sut.get('a')).to.deep.equal({ x: 10, y: 20 }); diff --git a/test/content/repositories/SettingRepository.test.ts b/test/content/repositories/SettingRepository.test.ts index db4c528..e45d7c4 100644 --- a/test/content/repositories/SettingRepository.test.ts +++ b/test/content/repositories/SettingRepository.test.ts @@ -4,9 +4,9 @@ import Settings from '../../../src/shared/settings/Settings'; describe('SettingRepositoryImpl', () => { it('updates and gets current value', () => { - let sut = new SettingRepositoryImpl(); + const sut = new SettingRepositoryImpl(); - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: {}, search:{ default: 'google', @@ -24,7 +24,7 @@ describe('SettingRepositoryImpl', () => { sut.set(settings); - let actual = sut.get(); + const actual = sut.get(); expect(actual.properties.hintchars).to.equal('abcd1234'); }); }); diff --git a/test/content/usecases/ClipboardUseCase.test.ts b/test/content/usecases/ClipboardUseCase.test.ts index a863651..2e711c6 100644 --- a/test/content/usecases/ClipboardUseCase.test.ts +++ b/test/content/usecases/ClipboardUseCase.test.ts @@ -14,7 +14,7 @@ describe('ClipboardUseCase', () => { let sut: ClipboardUseCase; beforeEach(() => { - var modal = <ConsoleClient>{}; + const modal = <ConsoleClient>{}; clipboardRepository = <ClipboardRepository>{ read() {}, write(_) {} }; operationClient = <OperationClient>{ internalOpenUrl(_) {} }; @@ -29,13 +29,13 @@ describe('ClipboardUseCase', () => { describe('#yankCurrentURL', () => { it('yanks current url', async () => { - let href = window.location.href; - var mockRepository = sinon.mock(clipboardRepository); + const href = window.location.href; + const mockRepository = sinon.mock(clipboardRepository); mockRepository.expects('write').withArgs(href); - var mockConsoleClient = sinon.mock(consoleClient); + const mockConsoleClient = sinon.mock(consoleClient); mockConsoleClient.expects('info').withArgs('Yanked ' + href); - let yanked = await sut.yankCurrentURL(); + const yanked = await sut.yankCurrentURL(); expect(yanked).to.equal(href); mockRepository.verify(); @@ -45,9 +45,9 @@ describe('ClipboardUseCase', () => { describe('#openOrSearch', () => { it('opens url from the clipboard', async () => { - let url = 'https://github.com/ueokande/vim-vixen' + const url = 'https://github.com/ueokande/vim-vixen' sinon.stub(clipboardRepository, 'read').returns(url); - let mockOperationClient = sinon.mock(operationClient); + const mockOperationClient = sinon.mock(operationClient); mockOperationClient.expects('internalOpenUrl').withArgs(url, true); await sut.openOrSearch(true); @@ -56,9 +56,9 @@ describe('ClipboardUseCase', () => { }); it('opens search results from the clipboard', async () => { - let url = 'https://google.com/search?q=banana'; + const url = 'https://google.com/search?q=banana'; sinon.stub(clipboardRepository, 'read').returns('banana'); - let mockOperationClient = sinon.mock(operationClient); + const mockOperationClient = sinon.mock(operationClient); mockOperationClient.expects('internalOpenUrl').withArgs(url, true); await sut.openOrSearch(true); diff --git a/test/content/usecases/FindUseCase.test.ts b/test/content/usecases/FindUseCase.test.ts index ddd4cd4..3978dbc 100644 --- a/test/content/usecases/FindUseCase.test.ts +++ b/test/content/usecases/FindUseCase.test.ts @@ -32,7 +32,7 @@ class MockFindPresenter implements FindPresenter { } find(keyword: string, _backward: boolean): boolean { - let found = this.document.includes(keyword); + const found = this.document.includes(keyword); this.highlighted = found; return found; } diff --git a/test/content/usecases/HintKeyProducer.test.ts b/test/content/usecases/HintKeyProducer.test.ts index feafffb..5841ae9 100644 --- a/test/content/usecases/HintKeyProducer.test.ts +++ b/test/content/usecases/HintKeyProducer.test.ts @@ -10,13 +10,13 @@ describe('HintKeyProducer class', () => { describe('#produce', () => { it('produce incremented keys', () => { - let charset = 'abc'; - let sequences = [ + const charset = 'abc'; + const sequences = [ 'a', 'b', 'c', 'aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc', 'aaa', 'aab', 'aac', 'aba'] - let producer = new HintKeyProducer(charset); + const producer = new HintKeyProducer(charset); for (let i = 0; i < sequences.length; ++i) { expect(producer.produce()).to.equal(sequences[i]); } diff --git a/test/content/usecases/KeymapUseCase.test.ts b/test/content/usecases/KeymapUseCase.test.ts index 598d5a3..032d4fc 100644 --- a/test/content/usecases/KeymapUseCase.test.ts +++ b/test/content/usecases/KeymapUseCase.test.ts @@ -52,7 +52,7 @@ class MockAddressRepository implements AddressRepository { describe('KeymapUseCase', () => { context('with no-digis keymaps', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { k: {type: 'scroll.vertically', count: -1}, j: {type: 'scroll.vertically', count: 1}, @@ -88,7 +88,7 @@ describe('KeymapUseCase', () => { }); context('when keymaps containing numeric mappings', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { 20: {type: "scroll.top"}, g5: {type: 'scroll.bottom'}, @@ -132,7 +132,7 @@ describe('KeymapUseCase', () => { }); context('when the keys are mismatched with the operations', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { gg: {type: "scroll.top"}, G: {type: "scroll.bottom"}, @@ -170,7 +170,7 @@ describe('KeymapUseCase', () => { }); context('when the site matches to the blacklist', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { k: {type: 'scroll.vertically', count: -1}, a: {type: 'addon.enable'}, @@ -197,7 +197,7 @@ describe('KeymapUseCase', () => { }); context('when the site matches to the partial blacklist', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { k: {type: 'scroll.vertically', count: -1}, j: {type: 'scroll.vertically', count: 1}, diff --git a/test/content/usecases/SettingUseCaase.test.ts b/test/content/usecases/SettingUseCaase.test.ts index 136c5af..cf14e6e 100644 --- a/test/content/usecases/SettingUseCaase.test.ts +++ b/test/content/usecases/SettingUseCaase.test.ts @@ -38,7 +38,7 @@ describe('AddonEnabledUseCase', () => { let sut: SettingUseCase; beforeEach(() => { - let testSettings = { + const testSettings = { keymaps: {}, search: { default: 'google', @@ -61,10 +61,10 @@ describe('AddonEnabledUseCase', () => { describe('#reload', () => { it('loads settings and store to repository', async() => { - let settings = await sut.reload(); + const settings = await sut.reload(); expect(settings.properties.hintchars).to.equal('abcd1234'); - let saved = repository.get(); + const saved = repository.get(); expect(saved.properties.hintchars).to.equal('abcd1234'); }); }); diff --git a/test/settings/components/form/BlacklistForm.test.tsx b/test/settings/components/form/BlacklistForm.test.tsx index 7daf513..6c329ff 100644 --- a/test/settings/components/form/BlacklistForm.test.tsx +++ b/test/settings/components/form/BlacklistForm.test.tsx @@ -10,11 +10,11 @@ import Blacklist from '../../../../src/shared/settings/Blacklist'; describe("settings/form/BlacklistForm", () => { describe('render', () => { it('renders BlacklistForm', () => { - let root = ReactTestRenderer.create( + const root = ReactTestRenderer.create( <BlacklistForm value={Blacklist.fromJSON(['*.slack.com', 'www.google.com/maps'])} />, ).root; - let children = root.children[0].children; + const children = root.children[0].children; expect(children).to.have.lengthOf(3); expect(children[0].children[0].props.value).to.equal('*.slack.com'); expect(children[1].children[0].props.value).to.equal('www.google.com/maps'); @@ -22,9 +22,9 @@ describe("settings/form/BlacklistForm", () => { }); it('renders blank value', () => { - let root = ReactTestRenderer.create(<BlacklistForm />).root; + const root = ReactTestRenderer.create(<BlacklistForm />).root; - let children = root.children[0].children; + const children = root.children[0].children; expect(children).to.have.lengthOf(1); expect(children[0].props.name).to.equal('add'); }); @@ -48,14 +48,14 @@ describe("settings/form/BlacklistForm", () => { ReactDOM.render(<BlacklistForm value={Blacklist.fromJSON(['*.slack.com', 'www.google.com/maps*'])} onChange={value => { - let urls = value.items.map(item => item.pattern); + const urls = value.items.map(item => item.pattern); expect(urls).to.have.members(['gitter.im', 'www.google.com/maps*']); done(); }} />, container) }); - let input = document.querySelectorAll('input[type=text]')[0]; + const input = document.querySelectorAll('input[type=text]')[0]; input.value = 'gitter.im'; ReactTestUtils.Simulate.change(input); }); @@ -65,14 +65,14 @@ describe("settings/form/BlacklistForm", () => { ReactDOM.render(<BlacklistForm value={Blacklist.fromJSON(['*.slack.com', 'www.google.com/maps*'])} onChange={value => { - let urls = value.items.map(item => item.pattern); + const urls = value.items.map(item => item.pattern); expect(urls).to.have.members(['www.google.com/maps*']); done(); }} />, container) }); - let button = document.querySelectorAll('input[type=button]')[0]; + const button = document.querySelectorAll('input[type=button]')[0]; ReactTestUtils.Simulate.click(button); }); @@ -81,14 +81,14 @@ describe("settings/form/BlacklistForm", () => { ReactDOM.render(<BlacklistForm value={Blacklist.fromJSON(['*.slack.com'])} onChange={value => { - let urls = value.items.map(item => item.pattern); + const urls = value.items.map(item => item.pattern); expect(urls).to.have.members(['*.slack.com', '']); done(); }} />, container); }); - let button = document.querySelector('input[type=button].ui-add-button'); + const button = document.querySelector('input[type=button].ui-add-button'); ReactTestUtils.Simulate.click(button); }); }); diff --git a/test/settings/components/form/KeymapsForm.test.tsx b/test/settings/components/form/KeymapsForm.test.tsx index 1d1e77c..ccc772c 100644 --- a/test/settings/components/form/KeymapsForm.test.tsx +++ b/test/settings/components/form/KeymapsForm.test.tsx @@ -9,23 +9,23 @@ import { expect } from 'chai'; describe("settings/form/KeymapsForm", () => { describe('render', () => { it('renders keymap fields', () => { - let root = ReactTestRenderer.create(<KeymapsForm value={FormKeymaps.fromJSON({ + const root = ReactTestRenderer.create(<KeymapsForm value={FormKeymaps.fromJSON({ 'scroll.vertically?{"count":1}': 'j', 'scroll.vertically?{"count":-1}': 'k', })} />).root - let inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); - let inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); + const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); + const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); expect(inputj.props.value).to.equal('j'); expect(inputk.props.value).to.equal('k'); }); it('renders blank value', () => { - let root = ReactTestRenderer.create(<KeymapsForm />).root; + const root = ReactTestRenderer.create(<KeymapsForm />).root; - let inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); - let inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); + const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); + const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); expect(inputj.props.value).to.be.empty; expect(inputk.props.value).to.be.empty; @@ -58,7 +58,7 @@ describe("settings/form/KeymapsForm", () => { }} />, container); }); - let input = document.getElementById('scroll.vertically?{"count":1}'); + const input = document.getElementById('scroll.vertically?{"count":1}'); input.value = 'jjj'; ReactTestUtils.Simulate.change(input); }); diff --git a/test/settings/components/form/PropertiesForm.test.tsx b/test/settings/components/form/PropertiesForm.test.tsx index 0e33cc8..4a0e25a 100644 --- a/test/settings/components/form/PropertiesForm.test.tsx +++ b/test/settings/components/form/PropertiesForm.test.tsx @@ -7,19 +7,19 @@ import PropertiesForm from 'settings/components/form/PropertiesForm' describe("settings/form/PropertiesForm", () => { describe('render', () => { it('renders PropertiesForm', () => { - let types = { + const types = { mystr: 'string', mynum: 'number', mybool: 'boolean', empty: 'string', } - let values = { + const values = { mystr: 'abc', mynum: 123, mybool: true, }; - let root = ReactTestRenderer.create( + const root = ReactTestRenderer.create( <PropertiesForm types={types} value={values} />, ).root @@ -62,7 +62,7 @@ describe("settings/form/PropertiesForm", () => { />, container); }); - let input = document.querySelector('input[name=myvalue]'); + const input = document.querySelector('input[name=myvalue]'); input.value = 'abcd' ReactTestUtils.Simulate.change(input); }); @@ -79,7 +79,7 @@ describe("settings/form/PropertiesForm", () => { />, container); }); - let input = document.querySelector('input[name=myvalue]'); + const input = document.querySelector('input[name=myvalue]'); input.value = '1234' ReactTestUtils.Simulate.change(input); }); @@ -96,7 +96,7 @@ describe("settings/form/PropertiesForm", () => { />, container); }); - let input = document.querySelector('input[name=myvalue]'); + const input = document.querySelector('input[name=myvalue]'); input.checked = true; ReactTestUtils.Simulate.change(input); }); diff --git a/test/settings/components/form/SearchEngineForm.test.tsx b/test/settings/components/form/SearchEngineForm.test.tsx index 1f0420d..b918203 100644 --- a/test/settings/components/form/SearchEngineForm.test.tsx +++ b/test/settings/components/form/SearchEngineForm.test.tsx @@ -8,17 +8,17 @@ import { FormSearch } from 'shared/SettingData'; describe("settings/form/SearchForm", () => { describe('render', () => { it('renders SearchForm', () => { - let root = ReactTestRenderer.create(<SearchForm value={FormSearch.fromJSON({ + const root = ReactTestRenderer.create(<SearchForm value={FormSearch.fromJSON({ default: 'google', engines: [['google', 'google.com'], ['yahoo', 'yahoo.com']], })} />).root; - let names = root.findAllByProps({ name: 'name' }); + const names = root.findAllByProps({ name: 'name' }); expect(names).to.have.lengthOf(2); expect(names[0].props.value).to.equal('google'); expect(names[1].props.value).to.equal('yahoo'); - let urls = root.findAllByProps({ name: 'url' }); + const urls = root.findAllByProps({ name: 'url' }); expect(urls).to.have.lengthOf(2); expect(urls[0].props.value).to.equal('google.com'); expect(urls[1].props.value).to.equal('yahoo.com'); @@ -46,7 +46,7 @@ describe("settings/form/SearchForm", () => { engines: [['google', 'google.com'], ['yahoo', 'yahoo.com']] })} onChange={value => { - let json = value.toJSON(); + const json = value.toJSON(); expect(json.default).to.equal('louvre'); expect(json.engines).to.have.lengthOf(2) expect(json.engines).to.have.deep.members( @@ -56,10 +56,10 @@ describe("settings/form/SearchForm", () => { }} />, container); }); - let radio = document.querySelectorAll('input[type=radio]'); + const radio = document.querySelectorAll('input[type=radio]'); radio.checked = true; - let name = document.querySelector('input[name=name]'); + const name = document.querySelector('input[name=name]'); name.value = 'louvre'; ReactTestUtils.Simulate.change(name); @@ -72,7 +72,7 @@ describe("settings/form/SearchForm", () => { engines: [['louvre', 'google.com'], ['yahoo', 'yahoo.com']] })} onChange={value => { - let json = value.toJSON(); + const json = value.toJSON(); expect(json.default).to.equal('yahoo'); expect(json.engines).to.have.lengthOf(1) expect(json.engines).to.have.deep.members( @@ -82,7 +82,7 @@ describe("settings/form/SearchForm", () => { }} />, container); }); - let button = document.querySelector('input[type=button]'); + const button = document.querySelector('input[type=button]'); ReactTestUtils.Simulate.click(button); }); @@ -93,7 +93,7 @@ describe("settings/form/SearchForm", () => { engines: [['google', 'google.com']] })} onChange={value => { - let json = value.toJSON(); + const json = value.toJSON(); expect(json.default).to.equal('yahoo'); expect(json.engines).to.have.lengthOf(2) expect(json.engines).to.have.deep.members( @@ -103,7 +103,7 @@ describe("settings/form/SearchForm", () => { }} />, container); }); - let button = document.querySelector('input[type=button].ui-add-button'); + const button = document.querySelector('input[type=button].ui-add-button'); ReactTestUtils.Simulate.click(button); }); }); diff --git a/test/settings/components/ui/input.test.tsx b/test/settings/components/ui/input.test.tsx index 432efcb..a3e7ff4 100644 --- a/test/settings/components/ui/input.test.tsx +++ b/test/settings/components/ui/input.test.tsx @@ -24,8 +24,8 @@ describe("settings/ui/Input", () => { container); }); - let label = document.querySelector('label'); - let input = document.querySelector('input'); + const label = document.querySelector('label'); + const input = document.querySelector('input'); expect(label.textContent).to.contain('myfield'); expect(input.type).to.contain('text'); expect(input.name).to.contain('myname'); @@ -40,7 +40,7 @@ describe("settings/ui/Input", () => { }}/>, container); }); - let input = document.querySelector('input'); + const input = document.querySelector('input'); input.value = 'newvalue'; ReactTestUtils.Simulate.change(input); }); @@ -54,8 +54,8 @@ describe("settings/ui/Input", () => { container); }); - let label = document.querySelector('label'); - let input = document.querySelector('input'); + const label = document.querySelector('label'); + const input = document.querySelector('input'); expect(label.textContent).to.contain('myfield'); expect(input.type).to.contain('radio'); expect(input.name).to.contain('myname'); @@ -71,7 +71,7 @@ describe("settings/ui/Input", () => { container); }); - let input = document.querySelector('input'); + const input = document.querySelector('input'); input.checked = true; ReactTestUtils.Simulate.change(input); }); @@ -85,9 +85,9 @@ describe("settings/ui/Input", () => { container); }); - let label = document.querySelector('label'); - let textarea = document.querySelector('textarea'); - let error = document.querySelector('.settings-ui-input-error'); + const label = document.querySelector('label'); + const textarea = document.querySelector('textarea'); + const error = document.querySelector('.settings-ui-input-error'); expect(label.textContent).to.contain('myfield'); expect(textarea.nodeName).to.contain('TEXTAREA'); expect(textarea.name).to.contain('myname'); @@ -103,7 +103,7 @@ describe("settings/ui/Input", () => { }}/>, container); }); - let input = document.querySelector('textarea'); + const input = document.querySelector('textarea'); input.value = 'newvalue' ReactTestUtils.Simulate.change(input); }); diff --git a/test/settings/reducers/setting.test.ts b/test/settings/reducers/setting.test.ts index 376d66e..60df061 100644 --- a/test/settings/reducers/setting.test.ts +++ b/test/settings/reducers/setting.test.ts @@ -3,51 +3,51 @@ import settingReducer from 'settings/reducers/setting'; describe("settings setting reducer", () => { it('return the initial state', () => { - let state = settingReducer(undefined, {}); + const state = settingReducer(undefined, {}); expect(state).to.have.deep.property('source', 'json'); expect(state).to.have.deep.property('error', ''); }); it('return next state for SETTING_SET_SETTINGS', () => { - let action = { + const action = { type: actions.SETTING_SET_SETTINGS, source: 'json', json: '{ "key": "value" }', form: {}, }; - let state = settingReducer(undefined, action); + const state = settingReducer(undefined, action); expect(state).to.have.deep.property('source', 'json'); expect(state).to.have.deep.property('json', '{ "key": "value" }'); expect(state).to.have.deep.property('form', {}); }); it('return next state for SETTING_SHOW_ERROR', () => { - let action = { + const action = { type: actions.SETTING_SHOW_ERROR, error: 'bad value', json: '{}', }; - let state = settingReducer(undefined, action); + const state = settingReducer(undefined, action); expect(state).to.have.deep.property('error', 'bad value'); expect(state).to.have.deep.property('json', '{}'); }); it('return next state for SETTING_SWITCH_TO_FORM', () => { - let action = { + const action = { type: actions.SETTING_SWITCH_TO_FORM, form: {}, }; - let state = settingReducer(undefined, action); + const state = settingReducer(undefined, action); expect(state).to.have.deep.property('form', {}); expect(state).to.have.deep.property('source', 'form'); }); it('return next state for SETTING_SWITCH_TO_JSON', () => { - let action = { + const action = { type: actions.SETTING_SWITCH_TO_JSON, json: '{}', }; - let state = settingReducer(undefined, action); + const state = settingReducer(undefined, action); expect(state).to.have.deep.property('json', '{}'); expect(state).to.have.deep.property('source', 'json'); }); 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'); |