From e1dac618a8b8929f601c7ec8aca3842c5ebf9d03 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 13 Apr 2020 20:37:36 +0900 Subject: Use plugin:prettier/recommended --- .eslintrc | 5 +- e2e/blacklist.test.ts | 54 +-- e2e/clipboard.test.ts | 108 ++--- e2e/command_addbookmark.test.ts | 47 +- e2e/command_bdelete.test.ts | 150 ++++--- e2e/command_buffer.test.ts | 104 ++--- e2e/command_help.test.ts | 34 +- e2e/command_open.test.ts | 97 ++--- e2e/command_quit.test.ts | 67 ++- e2e/command_tabopen.test.ts | 97 ++--- e2e/command_winopen.test.ts | 97 ++--- e2e/completion.test.ts | 75 ++-- e2e/completion_buffers.test.ts | 161 +++---- e2e/completion_open.test.ts | 177 +++++--- e2e/completion_set.test.ts | 47 +- e2e/console.test.ts | 75 ++-- e2e/eventually.ts | 12 +- e2e/find.test.ts | 64 +-- e2e/follow.test.ts | 203 +++++---- e2e/follow_properties.test.ts | 112 ++--- e2e/lib/Console.ts | 49 ++- e2e/lib/FormOptionPage.ts | 114 +++-- e2e/lib/JSONOptionPage.ts | 20 +- e2e/lib/OptionPage.ts | 16 +- e2e/lib/Page.ts | 63 ++- e2e/lib/SettingRepository.ts | 13 +- e2e/lib/TestServer.ts | 31 +- e2e/lib/clipboard.ts | 73 ++-- e2e/mark.test.ts | 76 ++-- e2e/navigate.test.ts | 206 +++++---- e2e/options.test.ts | 66 +-- e2e/options_form.test.ts | 107 ++--- e2e/partial_blacklist.test.ts | 58 +-- e2e/repeat.test.ts | 49 ++- e2e/repeat_n_times.test.ts | 47 +- e2e/scroll.test.ts | 93 ++-- e2e/tab.test.ts | 127 +++--- e2e/zoom.test.ts | 44 +- src/background/Application.ts | 16 +- src/background/clients/NavigateClient.ts | 4 +- src/background/completion/BookmarkRepository.ts | 6 +- src/background/completion/HistoryRepository.ts | 6 +- src/background/completion/OpenCompletionUseCase.ts | 48 ++- .../completion/PropertyCompletionUseCase.ts | 8 +- src/background/completion/TabCompletionUseCase.ts | 27 +- src/background/completion/TabItem.ts | 14 +- src/background/completion/TabRepository.ts | 16 +- .../completion/impl/BookmarkRepositoryImpl.ts | 29 +- .../completion/impl/HistoryRepositoryImpl.ts | 49 ++- src/background/completion/impl/PrefetchAndCache.ts | 37 +- .../completion/impl/TabRepositoryImpl.ts | 27 +- src/background/completion/impl/filters.ts | 45 +- .../controllers/AddonEnabledController.ts | 10 +- src/background/controllers/CommandController.ts | 87 ++-- src/background/controllers/CompletionController.ts | 26 +- src/background/controllers/FindController.ts | 9 +- src/background/controllers/LinkController.ts | 13 +- src/background/controllers/MarkController.ts | 9 +- src/background/controllers/OperationController.ts | 191 ++++---- src/background/controllers/SettingController.ts | 13 +- src/background/controllers/VersionController.ts | 9 +- src/background/di.ts | 31 +- src/background/index.ts | 8 +- src/background/infrastructures/ConsoleClient.ts | 7 +- .../infrastructures/ContentMessageClient.ts | 8 +- .../infrastructures/ContentMessageListener.ts | 153 +++---- src/background/infrastructures/MemoryStorage.ts | 6 +- src/background/presenters/HelpPresenter.ts | 4 +- src/background/presenters/IndicatorPresenter.ts | 9 +- src/background/presenters/Notifier.ts | 17 +- src/background/presenters/TabPresenter.ts | 35 +- src/background/presenters/WindowPresenter.ts | 2 +- src/background/repositories/BookmarkRepository.ts | 9 +- .../repositories/BrowserSettingRepository.ts | 15 +- .../repositories/CachedSettingRepository.ts | 39 +- src/background/repositories/FindRepository.ts | 7 +- src/background/repositories/MarkRepository.ts | 9 +- src/background/repositories/RepeatRepository.ts | 8 +- src/background/repositories/SettingRepository.ts | 12 +- src/background/usecases/AddonEnabledUseCase.ts | 12 +- src/background/usecases/CommandUseCase.ts | 54 +-- src/background/usecases/ConsoleUseCase.ts | 34 +- src/background/usecases/FindUseCase.ts | 15 +- src/background/usecases/LinkUseCase.ts | 15 +- src/background/usecases/MarkUseCase.ts | 26 +- src/background/usecases/NavigateUseCase.ts | 21 +- src/background/usecases/RepeatUseCase.ts | 55 ++- src/background/usecases/SettingUseCase.ts | 29 +- src/background/usecases/TabSelectUseCase.ts | 15 +- src/background/usecases/TabUseCase.ts | 29 +- src/background/usecases/VersionUseCase.ts | 15 +- src/background/usecases/ZoomUseCase.ts | 31 +- src/background/usecases/parsers.ts | 35 +- src/console/Completions.ts | 18 +- src/console/actions/console.ts | 233 +++++----- src/console/actions/index.ts | 34 +- src/console/clients/CompletionClient.ts | 65 +-- src/console/commandline/CommandLineParser.ts | 12 +- src/console/commandline/CommandParser.ts | 74 ++-- src/console/components/Console.tsx | 227 +++++----- src/console/components/console/Completion.tsx | 39 +- src/console/components/console/CompletionItem.tsx | 30 +- src/console/components/console/CompletionTitle.tsx | 6 +- src/console/components/console/Input.tsx | 20 +- src/console/components/console/Message.tsx | 26 +- src/console/index.tsx | 54 ++- src/console/reducers/index.ts | 128 +++--- src/content/Application.ts | 126 +++--- src/content/InputDriver.ts | 40 +- src/content/MessageListener.ts | 14 +- src/content/client/AddonIndicatorClient.ts | 2 +- src/content/client/ConsoleClient.ts | 2 +- src/content/client/FindClient.ts | 2 +- src/content/client/FindMasterClient.ts | 20 +- src/content/client/FollowMasterClient.ts | 6 +- src/content/client/FollowSlaveClient.ts | 4 +- src/content/client/FollowSlaveClientFactory.ts | 2 +- src/content/client/MarkClient.ts | 4 +- src/content/client/OperationClient.ts | 12 +- src/content/client/SettingClient.ts | 4 +- src/content/client/TabsClient.ts | 4 +- src/content/controllers/AddonEnabledController.ts | 13 +- src/content/controllers/ConsoleFrameController.ts | 11 +- src/content/controllers/FindController.ts | 11 +- src/content/controllers/FollowKeyController.ts | 11 +- src/content/controllers/FollowMasterController.ts | 17 +- src/content/controllers/FollowSlaveController.ts | 11 +- src/content/controllers/KeymapController.ts | 114 +++-- src/content/controllers/MarkController.ts | 11 +- src/content/controllers/MarkKeyController.ts | 13 +- src/content/controllers/NavigateController.ts | 11 +- src/content/controllers/SettingController.ts | 14 +- src/content/di.ts | 130 +++--- src/content/domains/KeySequence.ts | 29 +- src/content/domains/Mark.ts | 1 - src/content/hint-key-producer.ts | 6 +- src/content/index.ts | 18 +- src/content/presenters/ConsoleFramePresenter.ts | 12 +- src/content/presenters/FindPresenter.ts | 5 +- src/content/presenters/FocusPresenter.ts | 13 +- src/content/presenters/FollowPresenter.ts | 83 ++-- src/content/presenters/Hint.ts | 66 +-- src/content/presenters/NavigationPresenter.ts | 19 +- src/content/presenters/ScrollPresenter.ts | 20 +- src/content/repositories/AddressRepository.ts | 2 +- src/content/repositories/ClipboardRepository.ts | 22 +- src/content/repositories/FollowMasterRepository.ts | 3 +- src/content/repositories/FollowSlaveRepository.ts | 2 - src/content/repositories/KeymapRepository.ts | 5 +- src/content/repositories/MarkKeyRepository.ts | 1 - src/content/repositories/MarkRepository.ts | 4 +- src/content/repositories/SettingRepository.ts | 2 +- src/content/usecases/AddonEnabledUseCase.ts | 16 +- src/content/usecases/ClipboardUseCase.ts | 25 +- src/content/usecases/ConsoleFrameUseCase.ts | 11 +- src/content/usecases/FindSlaveUseCase.ts | 9 +- src/content/usecases/FindUseCase.ts | 31 +- src/content/usecases/FocusUseCase.ts | 9 +- src/content/usecases/FollowMasterUseCase.ts | 78 ++-- src/content/usecases/FollowSlaveUseCase.ts | 31 +- src/content/usecases/HintKeyProducer.ts | 7 +- src/content/usecases/KeymapUseCase.ts | 60 +-- src/content/usecases/MarkKeyUseCase.ts | 9 +- src/content/usecases/MarkUseCase.ts | 29 +- src/content/usecases/NavigateUseCase.ts | 11 +- src/content/usecases/ScrollUseCase.ts | 13 +- src/content/usecases/SettingUseCase.ts | 15 +- src/settings/actions/index.ts | 24 +- src/settings/actions/setting.ts | 39 +- src/settings/components/form/BlacklistForm.tsx | 71 +-- src/settings/components/form/KeymapsForm.tsx | 54 +-- .../components/form/PartialBlacklistForm.tsx | 100 +++-- src/settings/components/form/PropertiesForm.tsx | 66 +-- src/settings/components/form/SearchForm.tsx | 112 +++-- src/settings/components/index.tsx | 222 +++++----- src/settings/components/ui/AddButton.tsx | 15 +- src/settings/components/ui/DeleteButton.tsx | 15 +- src/settings/components/ui/Input.tsx | 89 ++-- src/settings/index.tsx | 23 +- src/settings/keymaps.ts | 137 +++--- src/settings/reducers/setting.ts | 64 +-- src/settings/storage.ts | 16 +- src/shared/Command.ts | 56 +-- src/shared/CompletionType.ts | 2 +- src/shared/SettingData.ts | 155 ++++--- src/shared/TabFlag.ts | 8 +- src/shared/messages.ts | 297 ++++++------- src/shared/operations.ts | 480 +++++++++++---------- src/shared/settings/Blacklist.ts | 39 +- src/shared/settings/Key.ts | 20 +- src/shared/settings/Keymaps.ts | 21 +- src/shared/settings/Properties.ts | 47 +- src/shared/settings/Search.ts | 10 +- src/shared/settings/Settings.ts | 31 +- src/shared/urls.ts | 24 +- src/shared/utils/dom.ts | 55 ++- .../completion/OpenCompletionUseCase.test.ts | 128 +++--- .../completion/PropertyCompletionUseCase.test.ts | 21 +- .../completion/TabCompletionUseCase.test.ts | 232 +++++++--- .../completion/impl/PrefetchAndCache.test.ts | 80 ++-- test/background/completion/impl/filters.test.ts | 98 ++--- .../infrastructures/MemoryStorage.test.ts | 48 +-- test/background/repositories/Mark.test.ts | 16 +- test/background/usecases/NavigateUseCase.test.ts | 94 ++-- test/background/usecases/SettingUseCase.test.ts | 73 ++-- test/background/usecases/parsers.test.ts | 47 +- test/console/actions/console.test.ts | 44 +- test/console/commandline/CommandLineParser.test.ts | 10 +- test/console/commandline/CommandParser.test.ts | 10 +- .../console/components/console/Completion.test.tsx | 195 ++++----- test/console/reducers/console.test.ts | 149 ++++--- test/content/InputDriver.test.ts | 161 ++++--- test/content/domains/KeySequence.test.ts | 209 ++++----- test/content/mock/MockConsoleClient.ts | 6 +- test/content/mock/MockScrollPresenter.ts | 7 +- test/content/presenters/Hint.test.ts | 134 +++--- .../content/presenters/NavigationPresenter.test.ts | 272 +++++++----- .../repositories/AddonEnabledRepository.test.ts | 9 +- test/content/repositories/FindRepository.test.ts | 13 +- .../repositories/FollowKeyRepository.test.ts | 26 +- .../repositories/FollowMasterRepository.test.ts | 39 +- .../repositories/FollowSlaveRepository.test.ts | 14 +- test/content/repositories/KeymapRepository.test.ts | 39 +- .../content/repositories/MarkKeyRepository.test.ts | 20 +- test/content/repositories/MarkRepository.test.ts | 15 +- .../content/repositories/SettingRepository.test.ts | 24 +- test/content/usecases/AddonEnabledUseCase.test.ts | 28 +- test/content/usecases/ClipboardUseCase.test.ts | 84 ++-- test/content/usecases/FindUseCase.test.ts | 87 ++-- test/content/usecases/HintKeyProducer.test.ts | 38 +- test/content/usecases/KeymapUseCase.test.ts | 274 +++++++----- test/content/usecases/MarkUseCase.test.ts | 75 ++-- test/content/usecases/SettingUseCaase.test.ts | 34 +- test/main.ts | 6 +- .../components/form/BlacklistForm.test.tsx | 112 ++--- test/settings/components/form/KeymapsForm.test.tsx | 68 +-- .../components/form/PropertiesForm.test.tsx | 121 +++--- .../components/form/SearchEngineForm.test.tsx | 165 ++++--- test/settings/components/ui/input.test.tsx | 145 ++++--- test/settings/reducers/setting.test.ts | 44 +- test/shared/SettingData.test.ts | 156 ++++--- test/shared/operations.test.ts | 46 +- test/shared/settings/Blacklist.test.ts | 210 +++++---- test/shared/settings/Key.test.ts | 120 +++--- test/shared/settings/Keymaps.test.ts | 81 ++-- test/shared/settings/Properties.test.ts | 21 +- test/shared/settings/Search.test.ts | 90 ++-- test/shared/settings/Settings.test.ts | 40 +- test/shared/urls.test.ts | 108 +++-- 249 files changed, 7228 insertions(+), 6194 deletions(-) diff --git a/.eslintrc b/.eslintrc index d08c3a6..67945d6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,10 +9,7 @@ "extends": [ "plugin:@typescript-eslint/recommended", "plugin:react/recommended", - "prettier", - "prettier/@typescript-eslint", - "prettier/react", - "prettier/standard" + "plugin:prettier/recommended" ], "plugins": [ "@typescript-eslint", diff --git a/e2e/blacklist.test.ts b/e2e/blacklist.test.ts index 79cdb47..db82726 100644 --- a/e2e/blacklist.test.ts +++ b/e2e/blacklist.test.ts @@ -1,57 +1,59 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import TestServer from './lib/TestServer'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import TestServer from "./lib/TestServer"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("blacklist test", () => { - const server = new TestServer().receiveContent('/*', - ``, + const server = new TestServer().receiveContent( + "/*", + `` ); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); await server.start(); - const url = server.url('/a').replace('http://', ''); - await new SettingRepository(browser).saveJSON(Settings.fromJSON({ - keymaps: { - j: { type: "scroll.vertically", count: 1 }, - }, - blacklist: [ url ], - })); + const url = server.url("/a").replace("http://", ""); + await new SettingRepository(browser).saveJSON( + Settings.fromJSON({ + keymaps: { + j: { type: "scroll.vertically", count: 1 }, + }, + blacklist: [url], + }) + ); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - it('should disable add-on if the URL is in the blacklist', async () => { - const page = await Page.navigateTo(webdriver, server.url('/a')); - await page.sendKeys('j'); + it("should disable add-on if the URL is in the blacklist", async () => { + const page = await Page.navigateTo(webdriver, server.url("/a")); + await page.sendKeys("j"); const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 0); }); - it('should enabled add-on if the URL is not in the blacklist', async () => { - const page = await Page.navigateTo(webdriver, server.url('/ab')); - await page.sendKeys('j'); + it("should enabled add-on if the URL is not in the blacklist", async () => { + const page = await Page.navigateTo(webdriver, server.url("/ab")); + await page.sendKeys("j"); const scrollY = await page.getScrollY(); assert.strictEqual(scrollY, 64); diff --git a/e2e/clipboard.test.ts b/e2e/clipboard.test.ts index 0a09c77..63a20a8 100644 --- a/e2e/clipboard.test.ts +++ b/e2e/clipboard.test.ts @@ -1,116 +1,120 @@ -import * as assert from 'assert'; -import * as path from 'path'; - -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import * as clipboard from './lib/clipboard'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver, Key } from 'selenium-webdriver'; -import Page from './lib/Page'; +import * as assert from "assert"; +import * as path from "path"; + +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import * as clipboard from "./lib/clipboard"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver, Key } from "selenium-webdriver"; +import Page from "./lib/Page"; import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("clipboard test", () => { - const server = new TestServer(12321).receiveContent('/happy', 'ok'); + const server = new TestServer(12321).receiveContent("/happy", "ok"); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); - await new SettingRepository(browser).saveJSON(Settings.fromJSON({ - search: { - default: "google", - engines: { - "google": "http://127.0.0.1:12321/google?q={}", + await new SettingRepository(browser).saveJSON( + Settings.fromJSON({ + search: { + default: "google", + engines: { + google: "http://127.0.0.1:12321/google?q={}", + }, }, - }, - })); + }) + ); await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { 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 () => { - const page = await Page.navigateTo(webdriver, server.url('/#should_copy_url')); - await page.sendKeys('y'); + it("should copy current URL by y", async () => { + const page = await Page.navigateTo( + webdriver, + server.url("/#should_copy_url") + ); + await page.sendKeys("y"); - await eventually(async() => { + await eventually(async () => { const data = await clipboard.read(); - assert.strictEqual(data, server.url('/#should_copy_url')); + assert.strictEqual(data, server.url("/#should_copy_url")); }); }); - it('should open an URL from clipboard by p', async () => { - await clipboard.write(server.url('/#open_from_clipboard')); + it("should open an URL from clipboard by p", async () => { + await clipboard.write(server.url("/#open_from_clipboard")); const page = await Page.navigateTo(webdriver, server.url()); - await page.sendKeys('p'); + await page.sendKeys("p"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); - assert.strictEqual(tabs[0].url, server.url('/#open_from_clipboard')); + assert.strictEqual(tabs[0].url, server.url("/#open_from_clipboard")); }); }); - it('should open an URL from clipboard to new tab by P', async () => { - await clipboard.write(server.url('/#open_to_new_tab')); + it("should open an URL from clipboard to new tab by P", async () => { + await clipboard.write(server.url("/#open_to_new_tab")); const page = await Page.navigateTo(webdriver, server.url()); - await page.sendKeys(Key.SHIFT, 'p'); + await page.sendKeys(Key.SHIFT, "p"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.deepStrictEqual(tabs.map((t: any) => t.url), [ - server.url(), - server.url('/#open_to_new_tab'), - ]); + assert.deepStrictEqual( + tabs.map((t: any) => t.url), + [server.url(), server.url("/#open_to_new_tab")] + ); }); }); - it('should open search result with keywords in clipboard by p', async () => { + it("should open search result with keywords in clipboard by p", async () => { await clipboard.write(`an apple`); const page = await Page.navigateTo(webdriver, server.url()); - await page.sendKeys(Key.SHIFT, 'p'); + await page.sendKeys(Key.SHIFT, "p"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); - assert.strictEqual(tabs[0].url, server.url('/google?q=an%20apple')); + assert.strictEqual(tabs[0].url, server.url("/google?q=an%20apple")); }); }); - it('should open search result with keywords in clipboard to new tabby P', async () => { + it("should open search result with keywords in clipboard to new tabby P", async () => { await clipboard.write(`an apple`); const page = await Page.navigateTo(webdriver, server.url()); - await page.sendKeys(Key.SHIFT, 'p'); + await page.sendKeys(Key.SHIFT, "p"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.deepStrictEqual(tabs.map((t: any) => t.url), [ - server.url(), - server.url('/google?q=an%20apple'), - ]); + 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 a54c103..4142e68 100644 --- a/e2e/command_addbookmark.test.ts +++ b/e2e/command_addbookmark.test.ts @@ -1,51 +1,54 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; -describe('addbookmark command test', () => { - const server = new TestServer().receiveContent('/happy', ` +describe("addbookmark command test", () => { + const server = new TestServer().receiveContent( + "/happy", + ` - how to be happy`, + how to be happy` ); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { - await webdriver.navigate().to(server.url('/happy')); + beforeEach(async () => { + await webdriver.navigate().to(server.url("/happy")); }); - it('should add a bookmark from the current page', async() => { + it("should add a bookmark from the current page", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('addbookmark how to be happy'); + await console.execCommand("addbookmark how to be happy"); - await eventually(async() => { - const bookmarks = await browser.bookmarks.search({ title: 'how to be happy' }); + await eventually(async () => { + const bookmarks = await browser.bookmarks.search({ + title: "how to be happy", + }); assert.strictEqual(bookmarks.length, 1); - assert.strictEqual(bookmarks[0].url, server.url('/happy')); + assert.strictEqual(bookmarks[0].url, server.url("/happy")); }); }); }); diff --git a/e2e/command_bdelete.test.ts b/e2e/command_bdelete.test.ts index c1f27ae..a85ce50 100644 --- a/e2e/command_bdelete.test.ts +++ b/e2e/command_bdelete.test.ts @@ -1,155 +1,165 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; -describe('bdelete/bdeletes command test', () => { - const server = new TestServer().receiveContent('/*', 'ok'); +describe("bdelete/bdeletes command test", () => { + const server = new TestServer().receiveContent("/*", "ok"); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { 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 }); - await browser.tabs.create({ url: server.url('/site2'), pinned: true }); - await browser.tabs.create({ url: server.url('/site3'), pinned: true }); - await browser.tabs.create({ url: server.url('/site4'), }); - await browser.tabs.create({ url: server.url('/site5'), }); + await browser.tabs.update(tabs[0].id, { + url: server.url("/site1"), + pinned: true, + }); + await browser.tabs.create({ url: server.url("/site2"), pinned: true }); + await browser.tabs.create({ url: server.url("/site3"), pinned: true }); + await browser.tabs.create({ url: server.url("/site4") }); + await browser.tabs.create({ url: server.url("/site5") }); - await eventually(async() => { + await eventually(async () => { 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() => { + it("should delete an unpinned tab by bdelete command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('bdelete site5'); + await console.execCommand("bdelete site5"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.deepStrictEqual(tabs.map((t: any) => t.url), [ - server.url('/site1'), - server.url('/site2'), - server.url('/site3'), - server.url('/site4'), - ]) + assert.deepStrictEqual( + tabs.map((t: any) => t.url), + [ + server.url("/site1"), + server.url("/site2"), + server.url("/site3"), + server.url("/site4"), + ] + ); }); }); - it('should not delete an pinned tab by bdelete command by bdelete command', async() => { + it("should not delete an pinned tab by bdelete command by bdelete command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('bdelete site1'); + await console.execCommand("bdelete site1"); - await eventually(async() => { + await eventually(async () => { 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() => { + it("should show an error when no tabs are matched by bdelete command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('bdelete xyz'); + await console.execCommand("bdelete xyz"); - await eventually(async() => { + await eventually(async () => { const text = await console.getErrorMessage(); - assert.strictEqual(text, 'No matching buffer for xyz'); + assert.strictEqual(text, "No matching buffer for xyz"); }); }); - it('should show an error when more than one tabs are matched by bdelete command', async() => { + it("should show an error when more than one tabs are matched by bdelete command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('bdelete site'); + await console.execCommand("bdelete site"); - await eventually(async() => { + await eventually(async () => { const text = await console.getErrorMessage(); - assert.strictEqual(text, 'More than one match for site'); + assert.strictEqual(text, "More than one match for site"); }); }); - it('should delete an unpinned tab by bdelete! command', async() => { + it("should delete an unpinned tab by bdelete! command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('bdelete! site5'); + await console.execCommand("bdelete! site5"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.deepStrictEqual(tabs.map((t: any) => t.url), [ - server.url('/site1'), - server.url('/site2'), - server.url('/site3'), - server.url('/site4'), - ]) + assert.deepStrictEqual( + tabs.map((t: any) => t.url), + [ + server.url("/site1"), + server.url("/site2"), + server.url("/site3"), + server.url("/site4"), + ] + ); }); }); - it('should delete an pinned tab by bdelete! command', async() => { + it("should delete an pinned tab by bdelete! command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('bdelete! site1'); + await console.execCommand("bdelete! site1"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.deepStrictEqual(tabs.map((t: any) => t.url), [ - server.url('/site2'), - server.url('/site3'), - server.url('/site4'), - server.url('/site5'), - ]) + assert.deepStrictEqual( + tabs.map((t: any) => t.url), + [ + server.url("/site2"), + server.url("/site3"), + server.url("/site4"), + server.url("/site5"), + ] + ); }); }); - it('should delete unpinned tabs by bdeletes command', async() => { + it("should delete unpinned tabs by bdeletes command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('bdeletes site'); + await console.execCommand("bdeletes site"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.deepStrictEqual(tabs.map((t: any) => t.url), [ - server.url('/site1'), - server.url('/site2'), - server.url('/site3'), - ]) + assert.deepStrictEqual( + tabs.map((t: any) => t.url), + [server.url("/site1"), server.url("/site2"), server.url("/site3")] + ); }); }); - it('should delete both pinned and unpinned tabs by bdeletes! command', async() => { + it("should delete both pinned and unpinned tabs by bdeletes! command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('bdeletes! site'); + await console.execCommand("bdeletes! site"); - await eventually(async() => { + await eventually(async () => { 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 3fa67ba..114f4b4 100644 --- a/e2e/command_buffer.test.ts +++ b/e2e/command_buffer.test.ts @@ -1,160 +1,162 @@ -import * as path from 'path'; -import * as assert from 'assert'; -import { Request, Response } from 'express'; - -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; - -describe('buffer command test', () => { - const server = new TestServer().handle('/*', (req: Request, res: Response) => { - res.send(` +import * as path from "path"; +import * as assert from "assert"; +import { Request, Response } from "express"; + +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; + +describe("buffer command test", () => { + const server = new TestServer().handle( + "/*", + (req: Request, res: Response) => { + res.send(` my_${req.path.slice(1)} `); - }); + } + ); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { 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') }); + await browser.tabs.update(tabs[0].id, { url: server.url("/site1") }); for (let i = 2; i <= 5; ++i) { - await browser.tabs.create({ url: server.url('/site' + i) }); + await browser.tabs.create({ url: server.url("/site" + i) }); } - await eventually(async() => { + await eventually(async () => { 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() => { + it("should do nothing by buffer command with no parameters", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('buffer'); + await console.execCommand("buffer"); - await eventually(async() => { + await eventually(async () => { 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() => { + it("should select a tab by buffer command with a number", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('buffer 1'); + await console.execCommand("buffer 1"); - await eventually(async() => { + await eventually(async () => { 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() => { + it("should should an out of range error by buffer commands", async () => { const page = await Page.currentContext(webdriver); let console = await page.showConsole(); - await console.execCommand('buffer 0'); + await console.execCommand("buffer 0"); - await eventually(async() => { + await eventually(async () => { const text = await console.getErrorMessage(); - assert.strictEqual(text, 'tab 0 does not exist'); + assert.strictEqual(text, "tab 0 does not exist"); }); await (webdriver.switchTo() as any).parentFrame(); console = await page.showConsole(); - await console.execCommand('buffer 9'); + await console.execCommand("buffer 9"); - await eventually(async() => { + await eventually(async () => { const text = await console.getErrorMessage(); - assert.strictEqual(text, 'tab 9 does not exist'); + assert.strictEqual(text, "tab 9 does not exist"); }); }); - it('should select a tab by buffer command with a title', async() => { + it("should select a tab by buffer command with a title", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('buffer my_site1'); + await console.execCommand("buffer my_site1"); - await eventually(async() => { + await eventually(async () => { 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() => { + it("should select a tab by buffer command with an URL", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('buffer /site1'); + await console.execCommand("buffer /site1"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); - it('should select tabs rotately', async() => { + it("should select tabs rotately", async () => { const handles = await webdriver.getAllWindowHandles(); await webdriver.switchTo().window(handles[4]); const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('buffer site'); + await console.execCommand("buffer site"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 0); }); }); - it('should do nothing by ":buffer %"', async() => { + it('should do nothing by ":buffer %"', async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('buffer %'); + await console.execCommand("buffer %"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); assert.strictEqual(tabs[0].index, 2); }); }); - it('should selects last selected tab by ":buffer #"', async() => { + it('should selects last selected tab by ":buffer #"', async () => { const handles = await webdriver.getAllWindowHandles(); await webdriver.switchTo().window(handles[1]); const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('buffer #'); + await console.execCommand("buffer #"); - await eventually(async() => { + await eventually(async () => { 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 9f8a459..40d4dde 100644 --- a/e2e/command_help.test.ts +++ b/e2e/command_help.test.ts @@ -1,11 +1,11 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; describe("help command test", () => { const server = new TestServer(); @@ -14,10 +14,9 @@ describe("help command test", () => { let browser: any; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); @@ -25,25 +24,24 @@ describe("help command test", () => { await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { page = await Page.navigateTo(webdriver, server.url()); }); - it('should open help page by help command ', async() => { + it("should open help page by help command ", async () => { const console = await page.showConsole(); - await console.execCommand('help'); + await console.execCommand("help"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); - assert.strictEqual(tabs[0].url, 'https://ueokande.github.io/vim-vixen/') + 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 f4d2aa1..2db522a 100644 --- a/e2e/command_open.test.ts +++ b/e2e/command_open.test.ts @@ -1,118 +1,119 @@ -import * as path from 'path'; -import * as assert from 'assert'; - -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import * as path from "path"; +import * as assert from "assert"; + +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("open command test", () => { const server = new TestServer() - .receiveContent('/google', 'google') - .receiveContent('/yahoo', 'yahoo'); + .receiveContent("/google", "google") + .receiveContent("/yahoo", "yahoo"); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); await server.start(); - await new SettingRepository(browser).saveJSON(Settings.fromJSON({ - search: { - default: "google", - engines: { - "google": server.url('/google?q={}'), - "yahoo": server.url('/yahoo?q={}'), + await new SettingRepository(browser).saveJSON( + Settings.fromJSON({ + search: { + default: "google", + engines: { + google: server.url("/google?q={}"), + yahoo: server.url("/yahoo?q={}"), + }, }, - }, - })); + }) + ); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { await webdriver.switchTo().defaultContent(); page = await Page.navigateTo(webdriver, server.url()); }); - it('should open default search for keywords by open command ', async() => { + it("should open default search for keywords by open command ", async () => { const console = await page.showConsole(); - await console.execCommand('open an apple'); + await console.execCommand("open an apple"); - await eventually(async() => { + await eventually(async () => { 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')) + assert.strictEqual(url.href, server.url("/google?q=an%20apple")); }); }); - it('should open certain search page for keywords by open command ', async() => { + it("should open certain search page for keywords by open command ", async () => { const console = await page.showConsole(); - await console.execCommand('open yahoo an apple'); + await console.execCommand("open yahoo an apple"); - await eventually(async() => { + await eventually(async () => { 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')) + assert.strictEqual(url.href, server.url("/yahoo?q=an%20apple")); }); }); - it('should open default engine with empty keywords by open command ', async() => { + it("should open default engine with empty keywords by open command ", async () => { const console = await page.showConsole(); - await console.execCommand('open'); + await console.execCommand("open"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); const url = new URL(tabs[0].url); - assert.strictEqual(url.href, server.url('/google?q=')) + assert.strictEqual(url.href, server.url("/google?q=")); }); }); - it('should open certain search page for empty keywords by open command ', async() => { + it("should open certain search page for empty keywords by open command ", async () => { const console = await page.showConsole(); - await console.execCommand('open yahoo'); + await console.execCommand("open yahoo"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); const url = new URL(tabs[0].url); - assert.strictEqual(url.href, server.url('/yahoo?q=')) + assert.strictEqual(url.href, server.url("/yahoo?q=")); }); }); - it('should open a site with domain by open command ', async() => { + it("should open a site with domain by open command ", async () => { const console = await page.showConsole(); - await console.execCommand('open example.com'); + await console.execCommand("open example.com"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); const url = new URL(tabs[0].url); - assert.strictEqual(url.href, 'http://example.com/') + assert.strictEqual(url.href, "http://example.com/"); }); }); - it('should open a site with URL by open command ', async() => { + it("should open a site with URL by open command ", async () => { const console = await page.showConsole(); - await console.execCommand('open https://example.com/'); + await console.execCommand("open https://example.com/"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({ active: true }); const url = new URL(tabs[0].url); - assert.strictEqual(url.href, 'https://example.com/') + assert.strictEqual(url.href, "https://example.com/"); }); }); }); diff --git a/e2e/command_quit.test.ts b/e2e/command_quit.test.ts index 037ad09..d59abfc 100644 --- a/e2e/command_quit.test.ts +++ b/e2e/command_quit.test.ts @@ -1,93 +1,92 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; -describe('quit/quitall command test', () => { - const server = new TestServer().receiveContent('/*', 'ok'); +describe("quit/quitall command test", () => { + const server = new TestServer().receiveContent("/*", "ok"); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { 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') }); + await browser.tabs.update(tabs[0].id, { url: server.url("/site1") }); for (let i = 2; i <= 5; ++i) { - await browser.tabs.create({ url: server.url('/site' + i) }) + await browser.tabs.create({ url: server.url("/site" + i) }); } - await eventually(async() => { + await eventually(async () => { const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); }); }); - it('should current tab by q command', async() => { + it("should current tab by q command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('q'); + await console.execCommand("q"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.strictEqual(tabs.length, 4) + assert.strictEqual(tabs.length, 4); }); }); - it('should current tab by quit command', async() => { + it("should current tab by quit command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('quit'); + await console.execCommand("quit"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.strictEqual(tabs.length, 4) + assert.strictEqual(tabs.length, 4); }); }); - it('should current tab by qa command', async() => { + it("should current tab by qa command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('qa'); + await console.execCommand("qa"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.strictEqual(tabs.length, 1) + assert.strictEqual(tabs.length, 1); }); }); - it('should current tab by quitall command', async() => { + it("should current tab by quitall command", async () => { const page = await Page.currentContext(webdriver); const console = await page.showConsole(); - await console.execCommand('quitall'); + await console.execCommand("quitall"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); - assert.strictEqual(tabs.length, 1) + assert.strictEqual(tabs.length, 1); }); }); }); diff --git a/e2e/command_tabopen.test.ts b/e2e/command_tabopen.test.ts index e96c29e..9807a03 100644 --- a/e2e/command_tabopen.test.ts +++ b/e2e/command_tabopen.test.ts @@ -1,51 +1,52 @@ -import * as path from 'path'; -import * as assert from 'assert'; - -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import * as path from "path"; +import * as assert from "assert"; + +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("tabopen command test", () => { const server = new TestServer() - .receiveContent('/google', 'google') - .receiveContent('/yahoo', 'yahoo'); + .receiveContent("/google", "google") + .receiveContent("/yahoo", "yahoo"); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); await server.start(); - await new SettingRepository(browser).saveJSON(Settings.fromJSON({ - search: { - default: "google", - engines: { - "google": server.url('/google?q={}'), - "yahoo": server.url('/yahoo?q={}'), + await new SettingRepository(browser).saveJSON( + Settings.fromJSON({ + search: { + default: "google", + engines: { + google: server.url("/google?q={}"), + yahoo: server.url("/yahoo?q={}"), + }, }, - }, - })); + }) + ); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { const tabs = await browser.tabs.query({}); for (const tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); @@ -54,75 +55,75 @@ describe("tabopen command test", () => { page = await Page.navigateTo(webdriver, server.url()); }); - it('should open default search for keywords by tabopen command ', async() => { + it("should open default search for keywords by tabopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('tabopen an apple'); + await console.execCommand("tabopen an apple"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); const url = new URL(tabs[1].url); - assert.strictEqual(url.href, server.url('/google?q=an%20apple') ) + assert.strictEqual(url.href, server.url("/google?q=an%20apple")); }); }); - it('should open certain search page for keywords by tabopen command ', async() => { + it("should open certain search page for keywords by tabopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('tabopen yahoo an apple'); + await console.execCommand("tabopen yahoo an apple"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); const url = new URL(tabs[1].url); - assert.strictEqual(url.href, server.url('/yahoo?q=an%20apple')) + assert.strictEqual(url.href, server.url("/yahoo?q=an%20apple")); }); }); - it('should open default engine with empty keywords by tabopen command ', async() => { + it("should open default engine with empty keywords by tabopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('tabopen'); + await console.execCommand("tabopen"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); const url = new URL(tabs[1].url); - assert.strictEqual(url.href, server.url('/google?q=')) + assert.strictEqual(url.href, server.url("/google?q=")); }); }); - it('should open certain search page for empty keywords by tabopen command ', async() => { + it("should open certain search page for empty keywords by tabopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('tabopen yahoo'); + await console.execCommand("tabopen yahoo"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); const url = new URL(tabs[1].url); - assert.strictEqual(url.href, server.url('/yahoo?q=')) + assert.strictEqual(url.href, server.url("/yahoo?q=")); }); }); - it('should open a site with domain by tabopen command ', async() => { + it("should open a site with domain by tabopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('tabopen example.com'); + await console.execCommand("tabopen example.com"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); const url = new URL(tabs[1].url); - assert.strictEqual(url.href, 'http://example.com/') + assert.strictEqual(url.href, "http://example.com/"); }); }); - it('should open a site with URL by tabopen command ', async() => { + it("should open a site with URL by tabopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('tabopen https://example.com/'); + await console.execCommand("tabopen https://example.com/"); - await eventually(async() => { + await eventually(async () => { const tabs = await browser.tabs.query({}); assert.strictEqual(tabs.length, 2); const url = new URL(tabs[1].url); - assert.strictEqual(url.href, 'https://example.com/') + assert.strictEqual(url.href, "https://example.com/"); }); }); }); diff --git a/e2e/command_winopen.test.ts b/e2e/command_winopen.test.ts index c9ff8d2..1d13edd 100644 --- a/e2e/command_winopen.test.ts +++ b/e2e/command_winopen.test.ts @@ -1,51 +1,52 @@ -import * as path from 'path'; -import * as assert from 'assert'; - -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import * as path from "path"; +import * as assert from "assert"; + +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; import SettingRepository from "./lib/SettingRepository"; import Settings from "../src/shared/settings/Settings"; describe("winopen command test", () => { const server = new TestServer() - .receiveContent('/google', 'google') - .receiveContent('/yahoo', 'yahoo'); + .receiveContent("/google", "google") + .receiveContent("/yahoo", "yahoo"); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); await server.start(); - await new SettingRepository(browser).saveJSON(Settings.fromJSON({ - search: { - default: "google", - engines: { - "google": server.url('/google?q={}'), - "yahoo": server.url('/yahoo?q={}'), + await new SettingRepository(browser).saveJSON( + Settings.fromJSON({ + search: { + default: "google", + engines: { + google: server.url("/google?q={}"), + yahoo: server.url("/yahoo?q={}"), + }, }, - }, - })); + }) + ); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { const wins = await browser.windows.getAll(); for (const win of wins.slice(1)) { await browser.windows.remove(win.id); @@ -54,87 +55,87 @@ describe("winopen command test", () => { page = await Page.navigateTo(webdriver, server.url()); }); - it('should open default search for keywords by winopen command ', async() => { + it("should open default search for keywords by winopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('winopen an apple'); + await console.execCommand("winopen an apple"); - await eventually(async() => { + await eventually(async () => { const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); 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')) + assert.strictEqual(url.href, server.url("/google?q=an%20apple")); }); }); - it('should open certain search page for keywords by winopen command ', async() => { + it("should open certain search page for keywords by winopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('winopen yahoo an apple'); + await console.execCommand("winopen yahoo an apple"); - await eventually(async() => { + await eventually(async () => { const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); 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')) + assert.strictEqual(url.href, server.url("/yahoo?q=an%20apple")); }); }); - it('should open default engine with empty keywords by winopen command ', async() => { + it("should open default engine with empty keywords by winopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('winopen'); + await console.execCommand("winopen"); - await eventually(async() => { + await eventually(async () => { const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); 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=')) + assert.strictEqual(url.href, server.url("/google?q=")); }); }); - it('should open certain search page for empty keywords by winopen command ', async() => { + it("should open certain search page for empty keywords by winopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('winopen yahoo'); + await console.execCommand("winopen yahoo"); - await eventually(async() => { + await eventually(async () => { const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); 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=')) + assert.strictEqual(url.href, server.url("/yahoo?q=")); }); }); - it('should open a site with domain by winopen command ', async() => { + it("should open a site with domain by winopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('winopen example.com'); + await console.execCommand("winopen example.com"); - await eventually(async() => { + await eventually(async () => { const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); const tabs = await browser.tabs.query({ windowId: wins[1].id }); const url = new URL(tabs[0].url); - assert.strictEqual(url.href, 'http://example.com/') + assert.strictEqual(url.href, "http://example.com/"); }); }); - it('should open a site with URL by winopen command ', async() => { + it("should open a site with URL by winopen command ", async () => { const console = await page.showConsole(); - await console.execCommand('winopen https://example.com/'); + await console.execCommand("winopen https://example.com/"); - await eventually(async() => { + await eventually(async () => { const wins = await browser.windows.getAll(); assert.strictEqual(wins.length, 2); const tabs = await browser.tabs.query({ windowId: wins[1].id }); const url = new URL(tabs[0].url); - assert.strictEqual(url.href, 'https://example.com/') + assert.strictEqual(url.href, "https://example.com/"); }); }); }); diff --git a/e2e/completion.test.ts b/e2e/completion.test.ts index 1ce430e..bc065d3 100644 --- a/e2e/completion.test.ts +++ b/e2e/completion.test.ts @@ -1,93 +1,98 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver, Key } from 'selenium-webdriver'; -import Page from './lib/Page'; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver, Key } from "selenium-webdriver"; +import Page from "./lib/Page"; describe("general completion test", () => { let lanthan: Lanthan; let webdriver: WebDriver; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); }); - after(async() => { + after(async () => { if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { - page = await Page.navigateTo(webdriver, 'about:blank'); + beforeEach(async () => { + page = await Page.navigateTo(webdriver, "about:blank"); }); - it('should all commands on empty line', async() => { + it("should all commands on empty line", async () => { const console = await page.showConsole(); const items = await console.getCompletions(); assert.strictEqual(items.length, 12); - assert.deepStrictEqual(items[0], { type: 'title', text: 'Console Command' }); - assert.ok(items[1].text.startsWith('set')); - assert.ok(items[2].text.startsWith('open')); - assert.ok(items[3].text.startsWith('tabopen')) + assert.deepStrictEqual(items[0], { + type: "title", + text: "Console Command", + }); + assert.ok(items[1].text.startsWith("set")); + assert.ok(items[2].text.startsWith("open")); + assert.ok(items[3].text.startsWith("tabopen")); }); - it('should only commands filtered by prefix', async() => { + it("should only commands filtered by prefix", async () => { const console = await page.showConsole(); - await console.inputKeys('b'); + await console.inputKeys("b"); 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')); - assert.ok(items[2].text.startsWith('bdelete')); - assert.ok(items[3].text.startsWith('bdeletes')) + assert.deepStrictEqual(items[0], { + type: "title", + text: "Console Command", + }); + assert.ok(items[1].text.startsWith("buffer")); + assert.ok(items[2].text.startsWith("bdelete")); + assert.ok(items[3].text.startsWith("bdeletes")); }); // > byffer // > bdelete // > bdeletes // : b - it('selects completion items by / keys', async() => { + it("selects completion items by / keys", async () => { const console = await page.showConsole(); - await console.inputKeys('b'); - await eventually(async() => { + await console.inputKeys("b"); + await eventually(async () => { const items = await console.getCompletions(); assert.strictEqual(items.length, 4); }); await console.sendKeys(Key.TAB); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); assert.ok(items[1].highlight); - assert.strictEqual(await console.currentValue(), 'buffer'); + assert.strictEqual(await console.currentValue(), "buffer"); }); await console.sendKeys(Key.TAB, Key.TAB); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); assert.ok(items[3].highlight); - assert.strictEqual(await console.currentValue(), 'bdeletes'); + assert.strictEqual(await console.currentValue(), "bdeletes"); }); await console.sendKeys(Key.TAB); - await eventually(async() => { - assert.strictEqual(await console.currentValue(), 'b'); + await eventually(async () => { + assert.strictEqual(await console.currentValue(), "b"); }); await console.sendKeys(Key.SHIFT, Key.TAB); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); assert.ok(items[3].highlight); - assert.strictEqual(await console.currentValue(), 'bdeletes'); + assert.strictEqual(await console.currentValue(), "bdeletes"); }); }); }); diff --git a/e2e/completion_buffers.test.ts b/e2e/completion_buffers.test.ts index ac24753..57603f6 100644 --- a/e2e/completion_buffers.test.ts +++ b/e2e/completion_buffers.test.ts @@ -1,32 +1,34 @@ -import * as assert from 'assert'; -import * as path from 'path'; +import * as assert from "assert"; +import * as path from "path"; -import { Request, Response } from 'express' -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import { Request, Response } from "express"; +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; describe("completion on buffer/bdelete/bdeletes", () => { - const server = new TestServer().handle('/*', (req: Request, res: Response) => { - res.send(` + const server = new TestServer().handle( + "/*", + (req: Request, res: Response) => { + res.send(` title_${req.path.slice(1)} `); - }); + } + ); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); @@ -34,26 +36,29 @@ describe("completion on buffer/bdelete/bdeletes", () => { await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { 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 }); - await browser.tabs.create({ url:server.url('/site2'), pinned: true }); + await browser.tabs.update(tabs[0].id, { + url: server.url("/site1"), + pinned: true, + }); + await browser.tabs.create({ url: server.url("/site2"), pinned: true }); for (let i = 3; i <= 5; ++i) { - await browser.tabs.create({ url: server.url('/site' + i) }); + await browser.tabs.create({ url: server.url("/site" + i) }); } - await eventually(async() => { + await eventually(async () => { const handles = await webdriver.getAllWindowHandles(); assert.strictEqual(handles.length, 5); await webdriver.switchTo().window(handles[2]); @@ -62,114 +67,114 @@ describe("completion on buffer/bdelete/bdeletes", () => { page = await Page.currentContext(webdriver); }); - it('should all tabs by "buffer" command with empty params', async() => { + it('should all tabs by "buffer" command with empty params', async () => { const console = await page.showConsole(); - await console.inputKeys('buffer '); + await console.inputKeys("buffer "); - await eventually(async() => { + await eventually(async () => { 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:')); - assert.ok(items[2].text.startsWith('2:')); - assert.ok(items[3].text.startsWith('3:')); - assert.ok(items[4].text.startsWith('4:')); - assert.ok(items[5].text.startsWith('5:')); - - assert.ok(items[3].text.includes('%')); - assert.ok(items[5].text.includes('#')); + assert.deepStrictEqual(items[0], { type: "title", text: "Buffers" }); + assert.ok(items[1].text.startsWith("1:")); + assert.ok(items[2].text.startsWith("2:")); + assert.ok(items[3].text.startsWith("3:")); + assert.ok(items[4].text.startsWith("4:")); + assert.ok(items[5].text.startsWith("5:")); + + assert.ok(items[3].text.includes("%")); + assert.ok(items[5].text.includes("#")); }); }); - it('should filter items with URLs by keywords on "buffer" command', async() => { + it('should filter items with URLs by keywords on "buffer" command', async () => { const console = await page.showConsole(); - await console.inputKeys('buffer title_site2'); + await console.inputKeys("buffer title_site2"); - await eventually(async() => { + await eventually(async () => { 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')); - assert.ok(items[1].text.includes(server.url('/site2'))); + assert.deepStrictEqual(items[0], { type: "title", text: "Buffers" }); + assert.ok(items[1].text.startsWith("2:")); + assert.ok(items[1].text.includes("title_site2")); + assert.ok(items[1].text.includes(server.url("/site2"))); }); }); - it('should filter items with titles by keywords on "buffer" command', async() => { + it('should filter items with titles by keywords on "buffer" command', async () => { const console = await page.showConsole(); - await console.inputKeys('buffer /site2'); + await console.inputKeys("buffer /site2"); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); - assert.deepStrictEqual(items[0], { type: 'title', text: 'Buffers' }); - assert.ok(items[1].text.startsWith('2:')); + 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() => { + it('should show one item by number on "buffer" command', async () => { const console = await page.showConsole(); - await console.inputKeys('buffer 2'); + await console.inputKeys("buffer 2"); - await eventually(async() => { + await eventually(async () => { 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:')); + assert.deepStrictEqual(items[0], { type: "title", text: "Buffers" }); + assert.ok(items[1].text.startsWith("2:")); }); }); - it('should show unpinned tabs "bdelete" command', async() => { + it('should show unpinned tabs "bdelete" command', async () => { const console = await page.showConsole(); - await console.inputKeys('bdelete site'); + await console.inputKeys("bdelete site"); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); assert.strictEqual(items.length, 4); - assert.ok(items[1].text.includes('site3')); - assert.ok(items[2].text.includes('site4')); - assert.ok(items[3].text.includes('site5')); + assert.ok(items[1].text.includes("site3")); + assert.ok(items[2].text.includes("site4")); + assert.ok(items[3].text.includes("site5")); }); }); - it('should show unpinned tabs "bdeletes" command', async() => { + it('should show unpinned tabs "bdeletes" command', async () => { const console = await page.showConsole(); - await console.inputKeys('bdeletes site'); + await console.inputKeys("bdeletes site"); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); assert.strictEqual(items.length, 4); - assert.ok(items[1].text.includes('site3')); - assert.ok(items[2].text.includes('site4')); - assert.ok(items[3].text.includes('site5')); + assert.ok(items[1].text.includes("site3")); + assert.ok(items[2].text.includes("site4")); + assert.ok(items[3].text.includes("site5")); }); }); - it('should show both pinned and unpinned tabs "bdelete!" command', async() => { + it('should show both pinned and unpinned tabs "bdelete!" command', async () => { const console = await page.showConsole(); - await console.inputKeys('bdelete! site'); + await console.inputKeys("bdelete! site"); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); assert.strictEqual(items.length, 6); - assert.ok(items[1].text.includes('site1')); - assert.ok(items[2].text.includes('site2')); - assert.ok(items[3].text.includes('site3')); - assert.ok(items[4].text.includes('site4')); - assert.ok(items[5].text.includes('site5')); + assert.ok(items[1].text.includes("site1")); + assert.ok(items[2].text.includes("site2")); + assert.ok(items[3].text.includes("site3")); + assert.ok(items[4].text.includes("site4")); + assert.ok(items[5].text.includes("site5")); }); }); - it('should show both pinned and unpinned tabs "bdeletes!" command', async() => { + it('should show both pinned and unpinned tabs "bdeletes!" command', async () => { const console = await page.showConsole(); - await console.inputKeys('bdeletes! site'); + await console.inputKeys("bdeletes! site"); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); assert.strictEqual(items.length, 6); - assert.ok(items[1].text.includes('site1')); - assert.ok(items[2].text.includes('site2')); - assert.ok(items[3].text.includes('site3')); - assert.ok(items[4].text.includes('site4')); - assert.ok(items[5].text.includes('site5')); + assert.ok(items[1].text.includes("site1")); + assert.ok(items[2].text.includes("site2")); + assert.ok(items[3].text.includes("site3")); + assert.ok(items[4].text.includes("site4")); + assert.ok(items[5].text.includes("site5")); }); }); }); diff --git a/e2e/completion_open.test.ts b/e2e/completion_open.test.ts index 95d4175..cefb44f 100644 --- a/e2e/completion_open.test.ts +++ b/e2e/completion_open.test.ts @@ -1,159 +1,202 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; import Settings from "../src/shared/settings/Settings"; -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; import SettingRepository from "./lib/SettingRepository"; describe("completion on open/tabopen/winopen commands", () => { - const server = new TestServer().receiveContent('/*', 'ok'); + const server = new TestServer().receiveContent("/*", "ok"); let lanthan: Lanthan; let webdriver: WebDriver; let browser: any; let page: Page; - before(async() => { + before(async () => { await server.start(); - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); browser = lanthan.getWebExtBrowser(); // Add item into hitories - await webdriver.navigate().to(('https://example.com/')); + await webdriver.navigate().to("https://example.com/"); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { page = await Page.navigateTo(webdriver, server.url()); }); - it('should show completions from search engines, bookmarks, and histories by "open" command', async() => { + it('should show completions from search engines, bookmarks, and histories by "open" command', async () => { const console = await page.showConsole(); - await console.inputKeys('open '); + await console.inputKeys("open "); - await eventually(async() => { + await eventually(async () => { 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')); + 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") + ); }); }); - it('should filter items with URLs by keywords on "open" command', async() => { + it('should filter items with URLs by keywords on "open" command', async () => { const console = await page.showConsole(); - await console.inputKeys('open https://'); + await console.inputKeys("open https://"); - await eventually(async() => { + await eventually(async () => { 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://'))); + 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() => { + it('should filter items with titles by keywords on "open" command', async () => { const console = await page.showConsole(); - await console.inputKeys('open getting'); + await console.inputKeys("open getting"); - await eventually(async() => { + await eventually(async () => { 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'))); + 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() => { + it('should filter items with titles by keywords on "tabopen" command', async () => { const console = await page.showConsole(); - await console.inputKeys('tabopen getting'); + await console.inputKeys("tabopen getting"); - await eventually(async() => { + await eventually(async () => { 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://'))); + 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() => { + it('should filter items with titles by keywords on "winopen" command', async () => { const console = await page.showConsole(); - await console.inputKeys('winopen https://'); + await console.inputKeys("winopen https://"); - await eventually(async() => { + await eventually(async () => { 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://'))); + const items = completions + .filter((x) => x.type === "item") + .map((x) => x.text); + assert.ok(items.every((x) => x.includes("https://"))); }); }); - it('should display only specified items in "complete" property by set command', async() => { + it('should display only specified items in "complete" property by set command', async () => { let console = await page.showConsole(); - await console.execCommand('set complete=sbh'); + await console.execCommand("set complete=sbh"); await (webdriver.switchTo() as any).parentFrame(); console = await page.showConsole(); - await console.inputKeys('open '); + await console.inputKeys("open "); - await eventually(async() => { + await eventually(async () => { const completions = await console.getCompletions(); - const titles = completions.filter(x => x.type === 'title').map(x => x.text); - assert.deepStrictEqual(titles, ['Search Engines', 'Bookmarks', 'History']) + const titles = completions + .filter((x) => x.type === "title") + .map((x) => x.text); + assert.deepStrictEqual(titles, [ + "Search Engines", + "Bookmarks", + "History", + ]); }); await console.close(); console = await page.showConsole(); - await console.execCommand('set complete=bss'); + await console.execCommand("set complete=bss"); await (webdriver.switchTo() as any).parentFrame(); console = await page.showConsole(); - await console.inputKeys('open '); + await console.inputKeys("open "); - await eventually(async() => { + await eventually(async () => { 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']) + const titles = completions + .filter((x) => x.type === "title") + .map((x) => x.text); + assert.deepStrictEqual(titles, [ + "Bookmarks", + "Search Engines", + "Search Engines", + ]); }); }); - it('should display only specified items in "complete" property by setting', async() => { - new SettingRepository(browser).saveJSON(Settings.fromJSON({ - properties: { complete: "sbh" }, - })); + it('should display only specified items in "complete" property by setting', async () => { + new SettingRepository(browser).saveJSON( + Settings.fromJSON({ + properties: { complete: "sbh" }, + }) + ); let console = await page.showConsole(); - await console.inputKeys('open '); + await console.inputKeys("open "); - await eventually(async() => { + await eventually(async () => { const completions = await console.getCompletions(); - const titles = completions.filter(x => x.type === 'title').map(x => x.text); - assert.deepStrictEqual(titles, ['Search Engines', 'Bookmarks', 'History']) + const titles = completions + .filter((x) => x.type === "title") + .map((x) => x.text); + assert.deepStrictEqual(titles, [ + "Search Engines", + "Bookmarks", + "History", + ]); }); await console.close(); await (webdriver.switchTo() as any).parentFrame(); - new SettingRepository(browser).saveJSON(Settings.fromJSON({ - properties: { complete: "bss" }, - })); + new SettingRepository(browser).saveJSON( + Settings.fromJSON({ + properties: { complete: "bss" }, + }) + ); console = await page.showConsole(); - await console.inputKeys('open '); + await console.inputKeys("open "); - await eventually(async() => { + await eventually(async () => { 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']) + 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 7e9714c..3a139fe 100644 --- a/e2e/completion_set.test.ts +++ b/e2e/completion_set.test.ts @@ -1,57 +1,56 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; describe("completion on set commands", () => { let lanthan: Lanthan; let webdriver: WebDriver; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); }); - after(async() => { + after(async () => { if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { page = await Page.navigateTo(webdriver, `about:blank`); }); - it('should show all property names by "set" command with empty params', async() => { + it('should show all property names by "set" command with empty params', async () => { const console = await page.showConsole(); - await console.inputKeys('set '); + await console.inputKeys("set "); - await eventually(async() => { + await eventually(async () => { 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')); - assert.ok(items[2].text.startsWith('smoothscroll')); - assert.ok(items[3].text.startsWith('nosmoothscroll')); - assert.ok(items[4].text.startsWith('complete')) + assert.deepStrictEqual(items[0], { type: "title", text: "Properties" }); + assert.ok(items[1].text.startsWith("hintchars")); + assert.ok(items[2].text.startsWith("smoothscroll")); + assert.ok(items[3].text.startsWith("nosmoothscroll")); + assert.ok(items[4].text.startsWith("complete")); }); }); - it('should show filtered property names by "set" command', async() => { + it('should show filtered property names by "set" command', async () => { const console = await page.showConsole(); - await console.inputKeys('set no'); + await console.inputKeys("set no"); - await eventually(async() => { + await eventually(async () => { const items = await console.getCompletions(); assert.strictEqual(items.length, 2); - assert.ok(items[1].text.includes('nosmoothscroll')) + assert.ok(items[1].text.includes("nosmoothscroll")); }); }); }); diff --git a/e2e/console.test.ts b/e2e/console.test.ts index 1d441f9..18b717f 100644 --- a/e2e/console.test.ts +++ b/e2e/console.test.ts @@ -1,90 +1,93 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import TestServer from './lib/TestServer'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver, Key } from 'selenium-webdriver'; -import Page from './lib/Page'; +import TestServer from "./lib/TestServer"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver, Key } from "selenium-webdriver"; +import Page from "./lib/Page"; describe("console test", () => { - const server = new TestServer().receiveContent('/', - `Hello, world!`, + const server = new TestServer().receiveContent( + "/", + `Hello, world!` ); let lanthan: Lanthan; let webdriver: WebDriver; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { page = await Page.navigateTo(webdriver, server.url()); }); - it('open console with :', async() => { - await page.sendKeys(':'); + it("open console with :", async () => { + await page.sendKeys(":"); const console = await page.getConsole(); - assert.strictEqual(await console.currentValue(), ''); + assert.strictEqual(await console.currentValue(), ""); }); - it('open console with open command by o', async() => { - await page.sendKeys('o'); + it("open console with open command by o", async () => { + await page.sendKeys("o"); const console = await page.getConsole(); - assert.strictEqual(await console.currentValue(), 'open '); + assert.strictEqual(await console.currentValue(), "open "); }); - it('open console with open command and current URL by O', async() => { - await page.sendKeys(Key.SHIFT, 'o'); + it("open console with open command and current URL by O", async () => { + await page.sendKeys(Key.SHIFT, "o"); 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'); + it("open console with tabopen command by t", async () => { + await page.sendKeys("t"); const console = await page.getConsole(); - assert.strictEqual(await console.currentValue(), 'tabopen '); + assert.strictEqual(await console.currentValue(), "tabopen "); }); - it('open console with tabopen command and current URL by T', async() => { - await page.sendKeys(Key.SHIFT, 't'); + it("open console with tabopen command and current URL by T", async () => { + await page.sendKeys(Key.SHIFT, "t"); 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'); + it("open console with winopen command by w", async () => { + await page.sendKeys("w"); 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'); + it("open console with winopen command and current URL by W", async () => { + await page.sendKeys(Key.SHIFT, "W"); 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'); + it("open console with buffer command by b", async () => { + await page.sendKeys("b"); 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'); + it("open console with addbookmark command with title by a", async () => { + await page.sendKeys("a"); const console = await page.getConsole(); - assert.strictEqual(await console.currentValue(), `addbookmark Hello, world!`); + assert.strictEqual( + await console.currentValue(), + `addbookmark Hello, world!` + ); }); }); diff --git a/e2e/eventually.ts b/e2e/eventually.ts index b0a2dfc..9d21022 100644 --- a/e2e/eventually.ts +++ b/e2e/eventually.ts @@ -1,19 +1,19 @@ const defaultInterval = 100; const defaultTimeout = 2000; -type Handler = () => void +type Handler = () => void; const sleep = (ms: number): Promise => { - return new Promise(resolve => setTimeout(resolve, ms)); -} - + return new Promise((resolve) => setTimeout(resolve, ms)); +}; + const eventually = async ( fn: Handler, timeout = defaultTimeout, - interval = defaultInterval, + interval = defaultInterval ): Promise => { const start = Date.now(); - const loop = async() => { + const loop = async () => { try { await fn(); } catch (err) { diff --git a/e2e/find.test.ts b/e2e/find.test.ts index 74097ab..accf37b 100644 --- a/e2e/find.test.ts +++ b/e2e/find.test.ts @@ -1,42 +1,42 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import eventually from './eventually'; -import TestServer from './lib/TestServer'; -import { Builder, Lanthan } from 'lanthan'; -import { Key, WebDriver } from 'selenium-webdriver'; -import Page from './lib/Page'; +import eventually from "./eventually"; +import TestServer from "./lib/TestServer"; +import { Builder, Lanthan } from "lanthan"; +import { Key, WebDriver } from "selenium-webdriver"; +import Page from "./lib/Page"; describe("find test", () => { - const server = new TestServer().receiveContent('/', - `--hello--hello--hello--`, + const server = new TestServer().receiveContent( + "/", + `--hello--hello--hello--` ); let lanthan: Lanthan; let webdriver: WebDriver; let page: Page; - before(async() => { - lanthan = await Builder - .forBrowser('firefox') - .spyAddon(path.join(__dirname, '..')) + before(async () => { + lanthan = await Builder.forBrowser("firefox") + .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); await server.start(); }); - after(async() => { + after(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); } }); - beforeEach(async() => { + beforeEach(async () => { page = await Page.navigateTo(webdriver, server.url()); }); - it('starts searching', async() => { - await page.sendKeys('/'); + it("starts searching", async () => { + await page.sendKeys("/"); const console = await page.getConsole(); await console.execCommand("hello"); await page.switchToTop(); @@ -60,53 +60,53 @@ describe("find test", () => { assert.deepStrictEqual(selection, { from: 16, to: 21 }); }); - it('shows error if pattern not found', async() => { - await page.sendKeys('/'); + it("shows error if pattern not found", async () => { + await page.sendKeys("/"); let console = await page.getConsole(); - await console.execCommand('world'); + await console.execCommand("world"); await page.switchToTop(); const selection = await page.getSelection(); assert.deepStrictEqual(selection, { from: 0, to: 0 }); - await eventually(async() => { + await eventually(async () => { console = await page.getConsole(); const message = await console.getErrorMessage(); - assert.strictEqual(message, 'Pattern not found: world'); + assert.strictEqual(message, "Pattern not found: world"); }); }); - it('search with last keyword if keyword is empty', async() => { - await page.sendKeys('/'); + it("search with last keyword if keyword is empty", async () => { + await page.sendKeys("/"); let console = await page.getConsole(); - await console.execCommand('hello'); + await console.execCommand("hello"); await page.switchToTop(); await page.clearSelection(); let selection = await page.getSelection(); assert.deepStrictEqual(selection, { from: 0, to: 0 }); - await page.sendKeys('/'); + await page.sendKeys("/"); console = await page.getConsole(); - await console.execCommand(''); + await console.execCommand(""); await page.switchToTop(); selection = await page.getSelection(); assert.deepStrictEqual(selection, { from: 2, to: 7 }); }); - it('search with last keyword on new page', async() => { - await page.sendKeys('/'); + it("search with last keyword on new page", async () => { + await page.sendKeys("/"); const console = await page.getConsole(); - await console.execCommand('hello'); + await console.execCommand("hello"); await page.switchToTop(); - await page.sendKeys('n'); + await page.sendKeys("n"); let selection = await page.getSelection(); assert.deepStrictEqual(selection, { from: 9, to: 14 }); page = await Page.navigateTo(webdriver, server.url()); - await page.sendKeys('n'); + await page.sendKeys("n"); selection = await page.getSelection(); assert.deepStrictEqual(selection, { from: 2, to: 7 }); }); diff --git a/e2e/follow.test.ts b/e2e/follow.test.ts index 62a109f..5fb6c58 100644 --- a/e2e/follow.test.ts +++ b/e2e/follow.test.ts @@ -1,28 +1,36 @@ -import * as path from 'path'; -import * as assert from 'assert'; +import * as path from "path"; +import * as assert from "assert"; -import TestServer from './lib/TestServer'; -import eventually from './eventually'; -import { Builder, Lanthan } from 'lanthan'; -import { WebDriver, Key } from 'selenium-webdriver'; -import Page from './lib/Page'; +import TestServer from "./lib/TestServer"; +import eventually from "./eventually"; +import { Builder, Lanthan } from "lanthan"; +import { WebDriver, Key } from "selenium-webdriver"; +import Page from "./lib/Page"; const newApp = () => { const server = new TestServer(); - server.receiveContent('/', ` + server.receiveContent( + "/", + ` hello - `); + ` + ); - server.receiveContent('/follow-input', ` + server.receiveContent( + "/follow-input", + ` - `); + ` + ); - server.receiveContent('/area', ` + server.receiveContent( + "/area", + ` { - `); + ` + ); /* * test case: link2 is out of the viewport @@ -46,168 +55,186 @@ const newApp = () => { * | | * +-----------------+ */ - server.receiveContent('/test1', ` + server.receiveContent( + "/test1", + `
- `); - -/* - * test case 2: link2 and link3 are out of window of the frame - * +-----------------+ - * | +-----------+ | - * | | [link1] | | - * |=================| - * | | [link2] | | - * | +-----------+ | - * | | - * +-----------------+ - */ - server.receiveContent('/test2', ` + ` + ); + + /* + * test case 2: link2 and link3 are out of window of the frame + * +-----------------+ + * | +-----------+ | + * | | [link1] | | + * |=================| + * | | [link2] | | + * | +-----------+ | + * | | + * +-----------------+ + */ + server.receiveContent( + "/test2", + `