aboutsummaryrefslogtreecommitdiff
path: root/test/background
diff options
context:
space:
mode:
Diffstat (limited to 'test/background')
-rw-r--r--test/background/completion/OpenCompletionUseCase.test.ts132
-rw-r--r--test/background/completion/PropertyCompletionUseCase.test.ts21
-rw-r--r--test/background/completion/TabCompletionUseCase.test.ts232
-rw-r--r--test/background/completion/impl/PrefetchAndCache.test.ts80
-rw-r--r--test/background/completion/impl/filters.test.ts98
-rw-r--r--test/background/infrastructures/MemoryStorage.test.ts49
-rw-r--r--test/background/repositories/Mark.test.ts17
-rw-r--r--test/background/usecases/NavigateUseCase.test.ts94
-rw-r--r--test/background/usecases/SettingUseCase.test.ts73
-rw-r--r--test/background/usecases/parsers.test.ts48
10 files changed, 531 insertions, 313 deletions
diff --git a/test/background/completion/OpenCompletionUseCase.test.ts b/test/background/completion/OpenCompletionUseCase.test.ts
index 421ce69..f43e6c1 100644
--- a/test/background/completion/OpenCompletionUseCase.test.ts
+++ b/test/background/completion/OpenCompletionUseCase.test.ts
@@ -1,42 +1,48 @@
import "reflect-metadata";
import CompletionType from "../../../src/shared/CompletionType";
-import BookmarkRepository, {BookmarkItem} from "../../../src/background/completion/BookmarkRepository";
-import HistoryRepository, {HistoryItem} from "../../../src/background/completion/HistoryRepository";
+import BookmarkRepository, {
+ BookmarkItem,
+} from "../../../src/background/completion/BookmarkRepository";
+import HistoryRepository, {
+ HistoryItem,
+} from "../../../src/background/completion/HistoryRepository";
import OpenCompletionUseCase from "../../../src/background/completion/OpenCompletionUseCase";
import CachedSettingRepository from "../../../src/background/repositories/CachedSettingRepository";
-import Settings, {DefaultSetting} from "../../../src/shared/settings/Settings";
-import { expect } from 'chai';
-import sinon from 'sinon';
+import Settings, {
+ DefaultSetting,
+} from "../../../src/shared/settings/Settings";
+import { expect } from "chai";
+import sinon from "sinon";
import Properties from "../../../src/shared/settings/Properties";
import Search from "../../../src/shared/settings/Search";
class MockBookmarkRepository implements BookmarkRepository {
queryBookmarks(_query: string): Promise<BookmarkItem[]> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
}
class MockHistoryRepository implements HistoryRepository {
queryHistories(_keywords: string): Promise<HistoryItem[]> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
}
class MockSettingRepository implements CachedSettingRepository {
get(): Promise<Settings> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
setProperty(_name: string, _value: string | number | boolean): Promise<void> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
update(_value: Settings): Promise<void> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
}
-describe('OpenCompletionUseCase', () => {
+describe("OpenCompletionUseCase", () => {
let bookmarkRepository: MockBookmarkRepository;
let historyRepository: MockHistoryRepository;
let settingRepository: MockSettingRepository;
@@ -46,63 +52,80 @@ describe('OpenCompletionUseCase', () => {
bookmarkRepository = new MockBookmarkRepository();
historyRepository = new MockHistoryRepository();
settingRepository = new MockSettingRepository();
- sut = new OpenCompletionUseCase(bookmarkRepository, historyRepository, settingRepository)
+ sut = new OpenCompletionUseCase(
+ bookmarkRepository,
+ historyRepository,
+ settingRepository
+ );
});
- describe('#getCompletionTypes', () => {
+ describe("#getCompletionTypes", () => {
it("returns completion types from the property", async () => {
- sinon.stub(settingRepository, 'get').returns(Promise.resolve(new Settings({
- keymaps: DefaultSetting.keymaps,
- search: DefaultSetting.search,
- properties: new Properties({ complete: "shb" }),
- blacklist: DefaultSetting.blacklist,
- })));
+ sinon.stub(settingRepository, "get").returns(
+ Promise.resolve(
+ new Settings({
+ keymaps: DefaultSetting.keymaps,
+ search: DefaultSetting.search,
+ properties: new Properties({ complete: "shb" }),
+ blacklist: DefaultSetting.blacklist,
+ })
+ )
+ );
const items = await sut.getCompletionTypes();
expect(items).to.deep.equal([
CompletionType.SearchEngines,
CompletionType.History,
- CompletionType.Bookmarks
+ CompletionType.Bookmarks,
]);
});
});
- describe('#requestSearchEngines', () => {
+ describe("#requestSearchEngines", () => {
it("returns search engines matches by the query", async () => {
- sinon.stub(settingRepository, 'get').returns(Promise.resolve(new Settings({
- keymaps: DefaultSetting.keymaps,
- search: new Search("google", {
- "google": "https://google.com/search?q={}",
- "yahoo": "https://search.yahoo.com/search?q={}",
- "bing": "https://bing.com/search?q={}",
- "google_ja": "https://google.co.jp/search?q={}",
- }),
- properties: DefaultSetting.properties,
- blacklist: DefaultSetting.blacklist,
- })));
+ sinon.stub(settingRepository, "get").returns(
+ Promise.resolve(
+ new Settings({
+ keymaps: DefaultSetting.keymaps,
+ search: new Search("google", {
+ google: "https://google.com/search?q={}",
+ yahoo: "https://search.yahoo.com/search?q={}",
+ bing: "https://bing.com/search?q={}",
+ googleja: "https://google.co.jp/search?q={}",
+ }),
+ properties: DefaultSetting.properties,
+ blacklist: DefaultSetting.blacklist,
+ })
+ )
+ );
expect(await sut.requestSearchEngines("")).to.deep.equal([
"google",
"yahoo",
"bing",
- "google_ja",
+ "googleja",
]);
expect(await sut.requestSearchEngines("go")).to.deep.equal([
"google",
- "google_ja",
+ "googleja",
]);
expect(await sut.requestSearchEngines("x")).to.be.empty;
- })
+ });
});
- describe('#requestBookmarks', () => {
- it("returns bookmarks from the repository", async() => {
- sinon.stub(bookmarkRepository, 'queryBookmarks')
- .withArgs("site").returns(Promise.resolve([
- { title: "site1", url: "https://site1.example.com" },
- { title: "site2", url: "https://site2.example.com/" },
- ]))
- .withArgs("xyz").returns(Promise.resolve([]));
+ describe("#requestBookmarks", () => {
+ it("returns bookmarks from the repository", async () => {
+ sinon
+ .stub(bookmarkRepository, "queryBookmarks")
+ .withArgs("site")
+ .returns(
+ Promise.resolve([
+ { title: "site1", url: "https://site1.example.com" },
+ { title: "site2", url: "https://site2.example.com/" },
+ ])
+ )
+ .withArgs("xyz")
+ .returns(Promise.resolve([]));
expect(await sut.requestBookmarks("site")).to.deep.equal([
{ title: "site1", url: "https://site1.example.com" },
@@ -112,14 +135,19 @@ describe('OpenCompletionUseCase', () => {
});
});
- describe('#requestHistory', () => {
- it("returns histories from the repository", async() => {
- sinon.stub(historyRepository, 'queryHistories')
- .withArgs("site").returns(Promise.resolve([
- { title: "site1", url: "https://site1.example.com" },
- { title: "site2", url: "https://site2.example.com/" },
- ]))
- .withArgs("xyz").returns(Promise.resolve([]));
+ describe("#requestHistory", () => {
+ it("returns histories from the repository", async () => {
+ sinon
+ .stub(historyRepository, "queryHistories")
+ .withArgs("site")
+ .returns(
+ Promise.resolve([
+ { title: "site1", url: "https://site1.example.com" },
+ { title: "site2", url: "https://site2.example.com/" },
+ ])
+ )
+ .withArgs("xyz")
+ .returns(Promise.resolve([]));
expect(await sut.requestHistory("site")).to.deep.equal([
{ title: "site1", url: "https://site1.example.com" },
@@ -128,4 +156,4 @@ describe('OpenCompletionUseCase', () => {
expect(await sut.requestHistory("xyz")).to.be.empty;
});
});
-}); \ No newline at end of file
+});
diff --git a/test/background/completion/PropertyCompletionUseCase.test.ts b/test/background/completion/PropertyCompletionUseCase.test.ts
index 57f5bff..dfc989f 100644
--- a/test/background/completion/PropertyCompletionUseCase.test.ts
+++ b/test/background/completion/PropertyCompletionUseCase.test.ts
@@ -1,15 +1,18 @@
-import 'reflect-metadata';
+import "reflect-metadata";
import PropertyCompletionUseCase from "../../../src/background/completion/PropertyCompletionUseCase";
-import { expect } from 'chai';
+import { expect } from "chai";
-describe('PropertyCompletionUseCase', () => {
- describe('getProperties', () => {
- it('returns property types', async () => {
+describe("PropertyCompletionUseCase", () => {
+ describe("getProperties", () => {
+ it("returns property types", async () => {
const sut = new PropertyCompletionUseCase();
const properties = await sut.getProperties();
- expect(properties).to.deep.contain({ name: 'smoothscroll', type: 'boolean' });
- expect(properties).to.deep.contain({ name: 'complete', type: 'string' });
- })
+ expect(properties).to.deep.contain({
+ name: "smoothscroll",
+ type: "boolean",
+ });
+ expect(properties).to.deep.contain({ name: "complete", type: "string" });
+ });
});
-}); \ No newline at end of file
+});
diff --git a/test/background/completion/TabCompletionUseCase.test.ts b/test/background/completion/TabCompletionUseCase.test.ts
index b9dc60b..d8aa385 100644
--- a/test/background/completion/TabCompletionUseCase.test.ts
+++ b/test/background/completion/TabCompletionUseCase.test.ts
@@ -1,85 +1,90 @@
-import "reflect-metadata"
+import "reflect-metadata";
import TabRepositoryImpl from "../../../src/background/completion/impl/TabRepositoryImpl";
-import {Tab} from "../../../src/background/completion/TabRepository";
+import { Tab } from "../../../src/background/completion/TabRepository";
import TabPresenter from "../../../src/background/presenters/TabPresenter";
import TabCompletionUseCase from "../../../src/background/completion/TabCompletionUseCase";
-import sinon from 'sinon';
-import { expect } from 'chai';
+import sinon from "sinon";
+import { expect } from "chai";
import TabFlag from "../../../src/shared/TabFlag";
class MockTabRepository implements TabRepositoryImpl {
async queryTabs(_query: string, _excludePinned: boolean): Promise<Tab[]> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
async getAllTabs(_excludePinned: boolean): Promise<Tab[]> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
}
class MockTabPresenter implements TabPresenter {
create(_url: string, _opts?: object): Promise<browser.tabs.Tab> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
duplicate(_id: number): Promise<browser.tabs.Tab> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
getAll(): Promise<browser.tabs.Tab[]> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
- getByKeyword(_keyword: string, _excludePinned: boolean): Promise<browser.tabs.Tab[]> {
- throw new Error("not implemented")
+ getByKeyword(
+ _keyword: string,
+ _excludePinned: boolean
+ ): Promise<browser.tabs.Tab[]> {
+ throw new Error("not implemented");
}
getCurrent(): Promise<browser.tabs.Tab> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
getLastSelectedId(): Promise<number | undefined> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
getZoom(_tabId: number): Promise<number> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
- onSelected(_listener: (arg: { tabId: number; windowId: number }) => void): void {
- throw new Error("not implemented")
+ onSelected(
+ _listener: (arg: { tabId: number; windowId: number }) => void
+ ): void {
+ throw new Error("not implemented");
}
open(_url: string, _tabId?: number): Promise<browser.tabs.Tab> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
reload(_tabId: number, _cache: boolean): Promise<void> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
remove(_ids: number[]): Promise<void> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
reopen(): Promise<any> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
select(_tabId: number): Promise<void> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
setPinned(_tabId: number, _pinned: boolean): Promise<void> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
setZoom(_tabId: number, _factor: number): Promise<void> {
- throw new Error("not implemented")
+ throw new Error("not implemented");
}
}
-describe('TabCompletionUseCase', () => {
+describe("TabCompletionUseCase", () => {
let tabRepository: MockTabRepository;
let tabPresenter: TabPresenter;
let sut: TabCompletionUseCase;
@@ -89,56 +94,169 @@ describe('TabCompletionUseCase', () => {
tabPresenter = new MockTabPresenter();
sut = new TabCompletionUseCase(tabRepository, tabPresenter);
- sinon.stub(tabPresenter, 'getLastSelectedId').returns(Promise.resolve(12));
- sinon.stub(tabRepository, 'getAllTabs').returns(Promise.resolve([
- { id: 10, index: 0, title: 'Google', url: 'https://google.com/', faviconUrl: 'https://google.com/favicon.ico', active: false },
- { id: 11, index: 1, title: 'Yahoo', url: 'https://yahoo.com/', faviconUrl: 'https://yahoo.com/favicon.ico', active: true },
- { id: 12, index: 2, title: 'Bing', url: 'https://bing.com/', active: false },
- ]));
+ sinon.stub(tabPresenter, "getLastSelectedId").returns(Promise.resolve(12));
+ sinon.stub(tabRepository, "getAllTabs").returns(
+ Promise.resolve([
+ {
+ id: 10,
+ index: 0,
+ title: "Google",
+ url: "https://google.com/",
+ faviconUrl: "https://google.com/favicon.ico",
+ active: false,
+ },
+ {
+ id: 11,
+ index: 1,
+ title: "Yahoo",
+ url: "https://yahoo.com/",
+ faviconUrl: "https://yahoo.com/favicon.ico",
+ active: true,
+ },
+ {
+ id: 12,
+ index: 2,
+ title: "Bing",
+ url: "https://bing.com/",
+ active: false,
+ },
+ ])
+ );
});
- describe('#queryTabs', () => {
+ describe("#queryTabs", () => {
it("returns tab items", async () => {
- sinon.stub(tabRepository, 'queryTabs').withArgs('', false).returns(Promise.resolve([
- { id: 10, index: 0, title: 'Google', url: 'https://google.com/', faviconUrl: 'https://google.com/favicon.ico', active: false },
- { id: 11, index: 1, title: 'Yahoo', url: 'https://yahoo.com/', faviconUrl: 'https://yahoo.com/favicon.ico', active: true },
- { id: 12, index: 2, title: 'Bing', url: 'https://bing.com/', active: false },
- ])).withArgs('oo', false).returns(Promise.resolve([
- { id: 10, index: 0, title: 'Google', url: 'https://google.com/', faviconUrl: 'https://google.com/favicon.ico', active: false },
- { id: 11, index: 1, title: 'Yahoo', url: 'https://yahoo.com/', faviconUrl: 'https://yahoo.com/favicon.ico', active: true },
- ]));
-
- expect(await sut.queryTabs('', false)).to.deep.equal([
- { index: 1, title: 'Google', url: 'https://google.com/', faviconUrl: 'https://google.com/favicon.ico', flag: TabFlag.None },
- { index: 2, title: 'Yahoo', url: 'https://yahoo.com/', faviconUrl: 'https://yahoo.com/favicon.ico', flag: TabFlag.CurrentTab },
- { index: 3, title: 'Bing', url: 'https://bing.com/', faviconUrl: undefined, flag: TabFlag.LastTab },
+ sinon
+ .stub(tabRepository, "queryTabs")
+ .withArgs("", false)
+ .returns(
+ Promise.resolve([
+ {
+ id: 10,
+ index: 0,
+ title: "Google",
+ url: "https://google.com/",
+ faviconUrl: "https://google.com/favicon.ico",
+ active: false,
+ },
+ {
+ id: 11,
+ index: 1,
+ title: "Yahoo",
+ url: "https://yahoo.com/",
+ faviconUrl: "https://yahoo.com/favicon.ico",
+ active: true,
+ },
+ {
+ id: 12,
+ index: 2,
+ title: "Bing",
+ url: "https://bing.com/",
+ active: false,
+ },
+ ])
+ )
+ .withArgs("oo", false)
+ .returns(
+ Promise.resolve([
+ {
+ id: 10,
+ index: 0,
+ title: "Google",
+ url: "https://google.com/",
+ faviconUrl: "https://google.com/favicon.ico",
+ active: false,
+ },
+ {
+ id: 11,
+ index: 1,
+ title: "Yahoo",
+ url: "https://yahoo.com/",
+ faviconUrl: "https://yahoo.com/favicon.ico",
+ active: true,
+ },
+ ])
+ );
+
+ expect(await sut.queryTabs("", false)).to.deep.equal([
+ {
+ index: 1,
+ title: "Google",
+ url: "https://google.com/",
+ faviconUrl: "https://google.com/favicon.ico",
+ flag: TabFlag.None,
+ },
+ {
+ index: 2,
+ title: "Yahoo",
+ url: "https://yahoo.com/",
+ faviconUrl: "https://yahoo.com/favicon.ico",
+ flag: TabFlag.CurrentTab,
+ },
+ {
+ index: 3,
+ title: "Bing",
+ url: "https://bing.com/",
+ faviconUrl: undefined,
+ flag: TabFlag.LastTab,
+ },
]);
- expect(await sut.queryTabs('oo', false)).to.deep.equal([
- { index: 1, title: 'Google', url: 'https://google.com/', faviconUrl: 'https://google.com/favicon.ico', flag: TabFlag.None },
- { index: 2, title: 'Yahoo', url: 'https://yahoo.com/', faviconUrl: 'https://yahoo.com/favicon.ico', flag: TabFlag.CurrentTab },
+ expect(await sut.queryTabs("oo", false)).to.deep.equal([
+ {
+ index: 1,
+ title: "Google",
+ url: "https://google.com/",
+ faviconUrl: "https://google.com/favicon.ico",
+ flag: TabFlag.None,
+ },
+ {
+ index: 2,
+ title: "Yahoo",
+ url: "https://yahoo.com/",
+ faviconUrl: "https://yahoo.com/favicon.ico",
+ flag: TabFlag.CurrentTab,
+ },
]);
});
it("returns a tab by the index", async () => {
- expect(await sut.queryTabs('1', false)).to.deep.equal([
- { index: 1, title: 'Google', url: 'https://google.com/', faviconUrl: 'https://google.com/favicon.ico', flag: TabFlag.None },
+ expect(await sut.queryTabs("1", false)).to.deep.equal([
+ {
+ index: 1,
+ title: "Google",
+ url: "https://google.com/",
+ faviconUrl: "https://google.com/favicon.ico",
+ flag: TabFlag.None,
+ },
]);
- expect(await sut.queryTabs('10', false)).to.be.empty;
- expect(await sut.queryTabs('-1', false)).to.be.empty;
+ expect(await sut.queryTabs("10", false)).to.be.empty;
+ expect(await sut.queryTabs("-1", false)).to.be.empty;
});
it("returns the current tab by % flag", async () => {
- expect(await sut.queryTabs('%', false)).to.deep.equal([
- { index: 2, title: 'Yahoo', url: 'https://yahoo.com/', faviconUrl: 'https://yahoo.com/favicon.ico', flag: TabFlag.CurrentTab },
+ expect(await sut.queryTabs("%", false)).to.deep.equal([
+ {
+ index: 2,
+ title: "Yahoo",
+ url: "https://yahoo.com/",
+ faviconUrl: "https://yahoo.com/favicon.ico",
+ flag: TabFlag.CurrentTab,
+ },
]);
});
it("returns the current tab by # flag", async () => {
- expect(await sut.queryTabs('#', false)).to.deep.equal([
- { index: 3, title: 'Bing', url: 'https://bing.com/', faviconUrl: undefined, flag: TabFlag.LastTab },
+ expect(await sut.queryTabs("#", false)).to.deep.equal([
+ {
+ index: 3,
+ title: "Bing",
+ url: "https://bing.com/",
+ faviconUrl: undefined,
+ flag: TabFlag.LastTab,
+ },
]);
- })
+ });
});
-}); \ No newline at end of file
+});
diff --git a/test/background/completion/impl/PrefetchAndCache.test.ts b/test/background/completion/impl/PrefetchAndCache.test.ts
index 23e3879..b24dfa9 100644
--- a/test/background/completion/impl/PrefetchAndCache.test.ts
+++ b/test/background/completion/impl/PrefetchAndCache.test.ts
@@ -1,39 +1,39 @@
-import PrefetchAndCache, {shortKey} from "../../../../src/background/completion/impl/PrefetchAndCache";
-import { expect } from 'chai';
+import PrefetchAndCache, {
+ shortKey,
+} from "../../../../src/background/completion/impl/PrefetchAndCache";
+import { expect } from "chai";
class MockRepository {
public history: string[] = [];
- constructor(
- private items: string[],
- ) {
- }
+ constructor(private items: string[]) {}
get(query: string): Promise<string[]> {
this.history.push(query);
if (query.length === 0) {
return Promise.resolve(this.items);
} else {
- return Promise.resolve(this.items.filter(item => item.includes(query)));
+ return Promise.resolve(this.items.filter((item) => item.includes(query)));
}
}
}
-const filter = (items: string[], query: string) => query.length === 0 ? items : items.filter(item => item.includes(query));
+const filter = (items: string[], query: string) =>
+ query.length === 0 ? items : items.filter((item) => item.includes(query));
-describe('shortKey', () => {
- it('returns query excluding the last word', () => {
- const query = "hello\t world good bye";
- const shorten = shortKey(query);
- expect(shorten).to.equal("hello world good")
+describe("shortKey", () => {
+ it("returns query excluding the last word", () => {
+ const query = "hello\t world good bye";
+ const shorten = shortKey(query);
+ expect(shorten).to.equal("hello world good");
});
- it('returns half-length of the query', () => {
+ it("returns half-length of the query", () => {
const query = "the-query-with-super-long-word";
const shorten = shortKey(query);
- expect(shorten).to.equal("the-query-with-")
+ expect(shorten).to.equal("the-query-with-");
});
- it('returns shorten URL', () => {
+ it("returns shorten URL", () => {
let query = "https://example.com/path/to/resource?q=hello";
let shorten = shortKey(query);
expect(shorten).to.equal("https://example.com/path/to/");
@@ -45,20 +45,39 @@ describe('shortKey', () => {
query = "https://www.google.c";
shorten = shortKey(query);
expect(shorten).to.equal("https://ww");
- })
+ });
});
-describe('PrefetchAndCache', () => {
- describe('get', () => {
- it('returns cached request', async() => {
- const repo = new MockRepository(["apple", "apple pie", "apple juice", "banana", "banana pudding", "cherry"]);
+describe("PrefetchAndCache", () => {
+ describe("get", () => {
+ it("returns cached request", async () => {
+ const repo = new MockRepository([
+ "apple",
+ "apple pie",
+ "apple juice",
+ "banana",
+ "banana pudding",
+ "cherry",
+ ]);
const sut = new PrefetchAndCache(repo.get.bind(repo), filter);
expect(await sut.get("apple pie")).deep.equal(["apple pie"]);
- expect(await sut.get("apple ")).deep.equal(["apple", "apple pie", "apple juice"]);
- expect(await sut.get("apple")).deep.equal(["apple", "apple pie", "apple juice"]);
- expect(await sut.get("appl")).deep.equal(["apple", "apple pie", "apple juice"]);
- expect(repo.history).to.deep.equal(["apple", 'ap']);
+ expect(await sut.get("apple ")).deep.equal([
+ "apple",
+ "apple pie",
+ "apple juice",
+ ]);
+ expect(await sut.get("apple")).deep.equal([
+ "apple",
+ "apple pie",
+ "apple juice",
+ ]);
+ expect(await sut.get("appl")).deep.equal([
+ "apple",
+ "apple pie",
+ "apple juice",
+ ]);
+ expect(repo.history).to.deep.equal(["apple", "ap"]);
expect(await sut.get("banana")).deep.equal(["banana", "banana pudding"]);
expect(repo.history).to.deep.equal(["apple", "ap", "ban"]);
@@ -68,7 +87,14 @@ describe('PrefetchAndCache', () => {
expect(repo.history).to.deep.equal(["apple", "ap", "ban", "banana", "b"]);
expect(await sut.get("")).to.have.lengthOf(6);
- expect(repo.history).to.deep.equal(["apple", "ap", "ban", "banana", "b", ""]);
+ expect(repo.history).to.deep.equal([
+ "apple",
+ "ap",
+ "ban",
+ "banana",
+ "b",
+ "",
+ ]);
});
});
-}); \ No newline at end of file
+});
diff --git a/test/background/completion/impl/filters.test.ts b/test/background/completion/impl/filters.test.ts
index a181f60..70c2663 100644
--- a/test/background/completion/impl/filters.test.ts
+++ b/test/background/completion/impl/filters.test.ts
@@ -1,87 +1,89 @@
-import * as filters from '../../../../src/background/completion/impl/filters'
-import { expect } from 'chai';
+import * as filters from "../../../../src/background/completion/impl/filters";
+import { expect } from "chai";
-describe('background/usecases/filters', () => {
- describe('filterHttp', () => {
- it('filters http URLs duplicates to https hosts', () => {
+describe("background/usecases/filters", () => {
+ describe("filterHttp", () => {
+ it("filters http URLs duplicates to https hosts", () => {
const pages = [
- { id: '0', url: 'http://i-beam.org/foo' },
- { id: '1', url: 'https://i-beam.org/bar' },
- { id: '2', url: 'http://i-beam.net/hoge' },
- { id: '3', url: 'http://i-beam.net/fuga' },
+ { id: "0", url: "http://i-beam.org/foo" },
+ { id: "1", url: "https://i-beam.org/bar" },
+ { id: "2", url: "http://i-beam.net/hoge" },
+ { id: "3", url: "http://i-beam.net/fuga" },
];
const filtered = filters.filterHttp(pages);
- const urls = filtered.map(x => x.url);
+ const urls = filtered.map((x) => x.url);
expect(urls).to.deep.equal([
- 'https://i-beam.org/bar', 'http://i-beam.net/hoge', 'http://i-beam.net/fuga'
+ "https://i-beam.org/bar",
+ "http://i-beam.net/hoge",
+ "http://i-beam.net/fuga",
]);
- })
+ });
});
- describe('filterBlankTitle', () => {
- it('filters blank titles', () => {
+ describe("filterBlankTitle", () => {
+ it("filters blank titles", () => {
const pages = [
- { id: '0', title: 'hello' },
- { id: '1', title: '' },
- { id: '2' },
+ { id: "0", title: "hello" },
+ { id: "1", title: "" },
+ { id: "2" },
];
const filtered = filters.filterBlankTitle(pages);
- expect(filtered).to.deep.equal([{ id: '0', title: 'hello' }]);
+ expect(filtered).to.deep.equal([{ id: "0", title: "hello" }]);
});
});
- describe('filterByTailingSlash', () => {
- it('filters duplicated pathname on tailing slash', () => {
+ describe("filterByTailingSlash", () => {
+ it("filters duplicated pathname on tailing slash", () => {
const pages = [
- { id: '0', url: 'http://i-beam.org/content' },
- { id: '1', url: 'http://i-beam.org/content/' },
- { id: '2', url: 'http://i-beam.org/search' },
- { id: '3', url: 'http://i-beam.org/search?q=apple_banana_cherry' },
+ { id: "0", url: "http://i-beam.org/content" },
+ { id: "1", url: "http://i-beam.org/content/" },
+ { id: "2", url: "http://i-beam.org/search" },
+ { id: "3", url: "http://i-beam.org/search?q=apple_banana_cherry" },
];
const filtered = filters.filterByTailingSlash(pages);
- const urls = filtered.map(x => x.url);
+ const urls = filtered.map((x) => x.url);
expect(urls).to.deep.equal([
- 'http://i-beam.org/content',
- 'http://i-beam.org/search',
- 'http://i-beam.org/search?q=apple_banana_cherry',
+ "http://i-beam.org/content",
+ "http://i-beam.org/search",
+ "http://i-beam.org/search?q=apple_banana_cherry",
]);
});
- })
+ });
- describe('filterByPathname', () => {
- it('filters by length of pathname', () => {
+ describe("filterByPathname", () => {
+ it("filters by length of pathname", () => {
const pages = [
- { id: '0', url: 'http://i-beam.org/search?q=apple' },
- { id: '1', url: 'http://i-beam.org/search?q=apple_banana' },
- { id: '2', url: 'http://i-beam.org/search?q=apple_banana_cherry' },
- { id: '3', url: 'http://i-beam.net/search?q=apple' },
- { id: '4', url: 'http://i-beam.net/search?q=apple_banana' },
- { id: '5', url: 'http://i-beam.net/search?q=apple_banana_cherry' },
+ { id: "0", url: "http://i-beam.org/search?q=apple" },
+ { id: "1", url: "http://i-beam.org/search?q=apple_banana" },
+ { id: "2", url: "http://i-beam.org/search?q=apple_banana_cherry" },
+ { id: "3", url: "http://i-beam.net/search?q=apple" },
+ { id: "4", url: "http://i-beam.net/search?q=apple_banana" },
+ { id: "5", url: "http://i-beam.net/search?q=apple_banana_cherry" },
];
const filtered = filters.filterByPathname(pages);
expect(filtered).to.deep.equal([
- { id: '0', url: 'http://i-beam.org/search?q=apple' },
- { id: '3', url: 'http://i-beam.net/search?q=apple' },
+ { id: "0", url: "http://i-beam.org/search?q=apple" },
+ { id: "3", url: "http://i-beam.net/search?q=apple" },
]);
});
});
- describe('filterByOrigin', () => {
- it('filters by length of pathname', () => {
+ describe("filterByOrigin", () => {
+ it("filters by length of pathname", () => {
const pages = [
- { id: '0', url: 'http://i-beam.org/search?q=apple' },
- { id: '1', url: 'http://i-beam.org/search?q=apple_banana' },
- { id: '2', url: 'http://i-beam.org/search?q=apple_banana_cherry' },
- { id: '3', url: 'http://i-beam.org/request?q=apple' },
- { id: '4', url: 'http://i-beam.org/request?q=apple_banana' },
- { id: '5', url: 'http://i-beam.org/request?q=apple_banana_cherry' },
+ { id: "0", url: "http://i-beam.org/search?q=apple" },
+ { id: "1", url: "http://i-beam.org/search?q=apple_banana" },
+ { id: "2", url: "http://i-beam.org/search?q=apple_banana_cherry" },
+ { id: "3", url: "http://i-beam.org/request?q=apple" },
+ { id: "4", url: "http://i-beam.org/request?q=apple_banana" },
+ { id: "5", url: "http://i-beam.org/request?q=apple_banana_cherry" },
];
const filtered = filters.filterByOrigin(pages);
expect(filtered).to.deep.equal([
- { id: '0', url: 'http://i-beam.org/search?q=apple' },
+ { id: "0", url: "http://i-beam.org/search?q=apple" },
]);
});
});
diff --git a/test/background/infrastructures/MemoryStorage.test.ts b/test/background/infrastructures/MemoryStorage.test.ts
index ccdf9f0..1c67b18 100644
--- a/test/background/infrastructures/MemoryStorage.test.ts
+++ b/test/background/infrastructures/MemoryStorage.test.ts
@@ -1,44 +1,45 @@
-import MemoryStorage from 'background/infrastructures/MemoryStorage';
+import MemoryStorage from "../../../src/background/infrastructures/MemoryStorage";
+import { expect } from "chai";
describe("background/infrastructures/memory-storage", () => {
- it('stores values', () => {
+ it("stores values", () => {
const cache = new MemoryStorage();
- cache.set('number', 123);
- expect(cache.get('number')).to.equal(123);
+ cache.set("number", 123);
+ expect(cache.get("number")).to.equal(123);
- cache.set('string', '123');
- expect(cache.get('string')).to.equal('123');
+ cache.set("string", "123");
+ expect(cache.get("string")).to.equal("123");
- cache.set('object', { hello: '123' });
- expect(cache.get('object')).to.deep.equal({ hello: '123' });
+ cache.set("object", { hello: "123" });
+ expect(cache.get("object")).to.deep.equal({ hello: "123" });
});
- it('returns undefined if no keys', () => {
+ it("returns undefined if no keys", () => {
const cache = new MemoryStorage();
- expect(cache.get('no-keys')).to.be.undefined;
- })
+ expect(cache.get("no-keys")).to.be.undefined;
+ });
- it('stored on shared memory', () => {
+ it("stored on shared memory", () => {
let cache = new MemoryStorage();
- cache.set('red', 'apple');
+ cache.set("red", "apple");
cache = new MemoryStorage();
- const got = cache.get('red');
- expect(got).to.equal('apple');
+ const got = cache.get("red");
+ expect(got).to.equal("apple");
});
- it('stored cloned objects', () => {
+ it("stored cloned objects", () => {
const cache = new MemoryStorage();
- const recipe = { sugar: '300g' };
- cache.set('recipe', recipe);
+ const recipe = { sugar: "300g", salt: "10g" };
+ cache.set("recipe", recipe);
- recipe.salt = '20g'
- const got = cache.get('recipe', recipe);
- expect(got).to.deep.equal({ sugar: '300g' });
+ recipe.salt = "20g";
+ const got = cache.get("recipe");
+ expect(got).to.deep.equal({ sugar: "300g", salt: "10g" });
});
- it('throws an error with unserializable objects', () => {
+ it("throws an error with unserializable objects", () => {
const cache = new MemoryStorage();
- expect(() => cache.set('fn', setTimeout)).to.throw();
- })
+ expect(() => cache.set("fn", setTimeout)).to.throw();
+ });
});
diff --git a/test/background/repositories/Mark.test.ts b/test/background/repositories/Mark.test.ts
index ed1a68e..5cee5b6 100644
--- a/test/background/repositories/Mark.test.ts
+++ b/test/background/repositories/Mark.test.ts
@@ -1,24 +1,25 @@
-import MarkRepository from 'background/repositories/MarkRepository';
+import MarkRepository from "../../../src/background/repositories/MarkRepository";
+import { expect } from "chai";
-describe('background/repositories/mark', () => {
+describe("background/repositories/mark", () => {
let repository: MarkRepository;
beforeEach(() => {
repository = new MarkRepository();
});
- it('get and set', async() => {
- const mark = { tabId: 1, url: 'http://example.com', x: 10, y: 30 };
+ it("get and set", async () => {
+ const mark = { tabId: 1, url: "http://example.com", x: 10, y: 30 };
- repository.setMark('A', mark);
+ await repository.setMark("A", mark);
- let got = await repository.getMark('A');
+ let got = (await repository.getMark("A"))!!;
expect(got.tabId).to.equal(1);
- expect(got.url).to.equal('http://example.com');
+ expect(got.url).to.equal("http://example.com");
expect(got.x).to.equal(10);
expect(got.y).to.equal(30);
- got = await repository.getMark('B');
+ got = (await repository.getMark("B"))!!;
expect(got).to.be.undefined;
});
});
diff --git a/test/background/usecases/NavigateUseCase.test.ts b/test/background/usecases/NavigateUseCase.test.ts
index 7ad0e4f..7263627 100644
--- a/test/background/usecases/NavigateUseCase.test.ts
+++ b/test/background/usecases/NavigateUseCase.test.ts
@@ -1,8 +1,8 @@
import "reflect-metadata";
-import TabPresenter from '../../../src/background/presenters/TabPresenter';
-import NavigateUseCase from '../../../src/background/usecases/NavigateUseCase';
-import NavigateClient from '../../../src/background/clients/NavigateClient';
-import * as sinon from 'sinon';
+import TabPresenter from "../../../src/background/presenters/TabPresenter";
+import NavigateUseCase from "../../../src/background/usecases/NavigateUseCase";
+import NavigateClient from "../../../src/background/clients/NavigateClient";
+import * as sinon from "sinon";
class MockTabPresenter implements TabPresenter {
create(_url: string, _opts?: object): Promise<browser.tabs.Tab> {
@@ -17,7 +17,10 @@ class MockTabPresenter implements TabPresenter {
throw new Error("not implemented");
}
- getByKeyword(_keyword: string, _excludePinned: boolean): Promise<browser.tabs.Tab[]> {
+ getByKeyword(
+ _keyword: string,
+ _excludePinned: boolean
+ ): Promise<browser.tabs.Tab[]> {
throw new Error("not implemented");
}
@@ -33,7 +36,9 @@ class MockTabPresenter implements TabPresenter {
throw new Error("not implemented");
}
- onSelected(_listener: (arg: { tabId: number; windowId: number }) => void): void {
+ onSelected(
+ _listener: (arg: { tabId: number; windowId: number }) => void
+ ): void {
throw new Error("not implemented");
}
@@ -66,7 +71,7 @@ class MockTabPresenter implements TabPresenter {
}
}
-describe('NavigateUseCase', () => {
+describe("NavigateUseCase", () => {
let sut: NavigateUseCase;
let tabPresenter: TabPresenter;
let navigateClient: NavigateClient;
@@ -80,7 +85,7 @@ describe('NavigateUseCase', () => {
const newTab = (url: string): browser.tabs.Tab => {
return {
index: 0,
- title: 'dummy title',
+ title: "dummy title",
url: url,
active: true,
hidden: false,
@@ -91,53 +96,67 @@ describe('NavigateUseCase', () => {
lastAccessed: 1585446733000,
pinned: false,
selected: false,
- windowId: 0
+ windowId: 0,
};
};
- describe('#openParent()', async () => {
- it('opens parent directory of file', async() => {
- sinon.stub(tabPresenter, 'getCurrent')
- .returns(Promise.resolve(newTab('https://google.com/fruits/yellow/banana')));
+ describe("#openParent()", async () => {
+ it("opens parent directory of file", async () => {
+ sinon
+ .stub(tabPresenter, "getCurrent")
+ .returns(
+ Promise.resolve(newTab("https://google.com/fruits/yellow/banana"))
+ );
- const mock = sinon.mock(tabPresenter)
- .expects('open').withArgs('https://google.com/fruits/yellow/');
+ const mock = sinon
+ .mock(tabPresenter)
+ .expects("open")
+ .withArgs("https://google.com/fruits/yellow/");
await sut.openParent();
mock.verify();
});
- it('opens parent directory of directory', async() => {
- sinon.stub(tabPresenter, 'getCurrent')
- .returns(Promise.resolve(newTab('https://google.com/fruits/yellow/')));
+ it("opens parent directory of directory", async () => {
+ sinon
+ .stub(tabPresenter, "getCurrent")
+ .returns(Promise.resolve(newTab("https://google.com/fruits/yellow/")));
- const mock = sinon.mock(tabPresenter)
- .expects('open').withArgs('https://google.com/fruits/');
+ const mock = sinon
+ .mock(tabPresenter)
+ .expects("open")
+ .withArgs("https://google.com/fruits/");
await sut.openParent();
mock.verify();
});
- it('removes hash', async() => {
- sinon.stub(tabPresenter, 'getCurrent')
- .returns(Promise.resolve(newTab('https://google.com/#top')));
+ it("removes hash", async () => {
+ sinon
+ .stub(tabPresenter, "getCurrent")
+ .returns(Promise.resolve(newTab("https://google.com/#top")));
- const mock = sinon.mock(tabPresenter)
- .expects('open').withArgs('https://google.com/');
+ const mock = sinon
+ .mock(tabPresenter)
+ .expects("open")
+ .withArgs("https://google.com/");
await sut.openParent();
mock.verify();
});
- it('removes search query', async() => {
- sinon.stub(tabPresenter, 'getCurrent')
- .returns(Promise.resolve(newTab('https://google.com/search?q=apple')));
+ it("removes search query", async () => {
+ sinon
+ .stub(tabPresenter, "getCurrent")
+ .returns(Promise.resolve(newTab("https://google.com/search?q=apple")));
- const mock = sinon.mock(tabPresenter)
- .expects('open').withArgs('https://google.com/search');
+ const mock = sinon
+ .mock(tabPresenter)
+ .expects("open")
+ .withArgs("https://google.com/search");
await sut.openParent();
@@ -145,13 +164,16 @@ describe('NavigateUseCase', () => {
});
});
- describe('#openRoot()', () => {
- it('opens root direectory', async() => {
- sinon.stub(tabPresenter, 'getCurrent')
- .returns(Promise.resolve(newTab('https://google.com/seach?q=apple')));
+ describe("#openRoot()", () => {
+ it("opens root direectory", async () => {
+ sinon
+ .stub(tabPresenter, "getCurrent")
+ .returns(Promise.resolve(newTab("https://google.com/seach?q=apple")));
- const mock = sinon.mock(tabPresenter)
- .expects('open').withArgs('https://google.com');
+ const mock = sinon
+ .mock(tabPresenter)
+ .expects("open")
+ .withArgs("https://google.com");
await sut.openRoot();
diff --git a/test/background/usecases/SettingUseCase.test.ts b/test/background/usecases/SettingUseCase.test.ts
index bfa599c..c604e91 100644
--- a/test/background/usecases/SettingUseCase.test.ts
+++ b/test/background/usecases/SettingUseCase.test.ts
@@ -1,21 +1,22 @@
import "reflect-metadata";
import SettingUseCase from "../../../src/background/usecases/SettingUseCase";
import SettingRepository from "../../../src/background/repositories/SettingRepository";
-import SettingData, {JSONTextSettings} from "../../../src/shared/SettingData";
+import SettingData, { JSONTextSettings } from "../../../src/shared/SettingData";
import CachedSettingRepository from "../../../src/background/repositories/CachedSettingRepository";
-import Settings, {DefaultSetting} from "../../../src/shared/settings/Settings";
+import Settings, {
+ DefaultSetting,
+} from "../../../src/shared/settings/Settings";
import Notifier from "../../../src/background/presenters/Notifier";
-import {expect} from "chai";
+import { expect } from "chai";
import Properties from "../../../src/shared/settings/Properties";
-import sinon from 'sinon';
+import sinon from "sinon";
class MockSettingRepository implements SettingRepository {
load(): Promise<SettingData | null> {
throw new Error("not implemented");
}
- onChange(_: () => void): void {
- }
+ onChange(_: () => void): void {}
}
class MockCachedSettingRepository implements CachedSettingRepository {
@@ -46,12 +47,12 @@ class NopNotifier implements Notifier {
}
}
-describe('SettingUseCase', () => {
- let localSettingRepository : SettingRepository;
- let syncSettingRepository : SettingRepository;
- let cachedSettingRepository : CachedSettingRepository;
+describe("SettingUseCase", () => {
+ let localSettingRepository: SettingRepository;
+ let syncSettingRepository: SettingRepository;
+ let cachedSettingRepository: CachedSettingRepository;
let notifier: Notifier;
- let sut : SettingUseCase;
+ let sut: SettingUseCase;
beforeEach(() => {
localSettingRepository = new MockSettingRepository();
@@ -66,34 +67,34 @@ describe('SettingUseCase', () => {
);
});
- describe('getCached', () => {
+ describe("getCached", () => {
it("returns cached settings", async () => {
const settings = new Settings({
keymaps: DefaultSetting.keymaps,
search: DefaultSetting.search,
blacklist: DefaultSetting.blacklist,
properties: new Properties({
- hintchars: "abcd1234"
+ hintchars: "abcd1234",
}),
});
- sinon.stub(cachedSettingRepository, "get")
+ sinon
+ .stub(cachedSettingRepository, "get")
.returns(Promise.resolve(settings));
const got = await sut.getCached();
expect(got.properties.hintchars).to.equal("abcd1234");
-
});
});
describe("reload", () => {
context("when sync is not set", () => {
- it("loads settings from local storage", async() => {
+ it("loads settings from local storage", async () => {
const settings = new Settings({
keymaps: DefaultSetting.keymaps,
search: DefaultSetting.search,
blacklist: DefaultSetting.blacklist,
properties: new Properties({
- hintchars: "abcd1234"
+ hintchars: "abcd1234",
}),
});
const settingData = SettingData.fromJSON({
@@ -101,9 +102,11 @@ describe('SettingUseCase', () => {
json: JSONTextSettings.fromSettings(settings).toJSONText(),
});
- sinon.stub(syncSettingRepository, "load")
+ sinon
+ .stub(syncSettingRepository, "load")
.returns(Promise.resolve(null));
- sinon.stub(localSettingRepository, "load")
+ sinon
+ .stub(localSettingRepository, "load")
.returns(Promise.resolve(settingData));
await sut.reload();
@@ -114,13 +117,13 @@ describe('SettingUseCase', () => {
});
context("when local is not set", () => {
- it("loads settings from sync storage", async() => {
+ it("loads settings from sync storage", async () => {
const settings = new Settings({
keymaps: DefaultSetting.keymaps,
search: DefaultSetting.search,
blacklist: DefaultSetting.blacklist,
properties: new Properties({
- hintchars: "aaaa1111"
+ hintchars: "aaaa1111",
}),
});
const settingData = SettingData.fromJSON({
@@ -128,9 +131,11 @@ describe('SettingUseCase', () => {
json: JSONTextSettings.fromSettings(settings).toJSONText(),
});
- sinon.stub(syncSettingRepository, "load")
+ sinon
+ .stub(syncSettingRepository, "load")
.returns(Promise.resolve(settingData));
- sinon.stub(localSettingRepository, "load")
+ sinon
+ .stub(localSettingRepository, "load")
.returns(Promise.resolve(null));
await sut.reload();
@@ -141,21 +146,23 @@ describe('SettingUseCase', () => {
});
context("neither local nor sync not set", () => {
- it("loads default settings", async() => {
- it("loads settings from sync storage", async() => {
- sinon.stub(syncSettingRepository, "load")
+ it("loads default settings", async () => {
+ it("loads settings from sync storage", async () => {
+ sinon
+ .stub(syncSettingRepository, "load")
.returns(Promise.resolve(null));
- sinon.stub(localSettingRepository, "load")
+ sinon
+ .stub(localSettingRepository, "load")
.returns(Promise.resolve(null));
await sut.reload();
const current = await cachedSettingRepository.get();
- expect(current.properties.hintchars).to.equal(DefaultSetting.properties.hintchars);
+ expect(current.properties.hintchars).to.equal(
+ DefaultSetting.properties.hintchars
+ );
});
-
- })
- })
- })
+ });
+ });
+ });
});
-
diff --git a/test/background/usecases/parsers.test.ts b/test/background/usecases/parsers.test.ts
index d08de0d..019b56e 100644
--- a/test/background/usecases/parsers.test.ts
+++ b/test/background/usecases/parsers.test.ts
@@ -1,34 +1,44 @@
-import * as parsers from 'background/usecases/parsers';
+import * as parsers from "../../../src/background/usecases/parsers";
+import { expect } from "chai";
describe("shared/commands/parsers", () => {
describe("#parsers.parseSetOption", () => {
- it('parse set string', () => {
- const [key, value] = parsers.parseSetOption('hintchars=abcdefgh');
- expect(key).to.equal('hintchars');
- expect(value).to.equal('abcdefgh');
+ it("parse set string", () => {
+ const [key, value] = parsers.parseSetOption("hintchars=abcdefgh");
+ expect(key).to.equal("hintchars");
+ expect(value).to.equal("abcdefgh");
});
- it('parse set empty string', () => {
- const [key, value] = parsers.parseSetOption('hintchars=');
- expect(key).to.equal('hintchars');
- expect(value).to.equal('');
+ it("parse set empty string", () => {
+ const [key, value] = parsers.parseSetOption("hintchars=");
+ expect(key).to.equal("hintchars");
+ expect(value).to.equal("");
});
- it('parse set boolean', () => {
- let [key, value] = parsers.parseSetOption('smoothscroll');
- expect(key).to.equal('smoothscroll');
+ it("parse set boolean", () => {
+ let [key, value] = parsers.parseSetOption("smoothscroll");
+ expect(key).to.equal("smoothscroll");
expect(value).to.be.true;
- [key, value] = parsers.parseSetOption('nosmoothscroll');
- expect(key).to.equal('smoothscroll');
+ [key, value] = parsers.parseSetOption("nosmoothscroll");
+ expect(key).to.equal("smoothscroll");
expect(value).to.be.false;
});
- it('throws error on unknown property', () => {
- expect(() => parsers.parseSetOption('encoding=utf-8')).to.throw(Error, 'Unknown');
- expect(() => parsers.parseSetOption('paste')).to.throw(Error, 'Unknown');
- expect(() => parsers.parseSetOption('nopaste')).to.throw(Error, 'Unknown');
- expect(() => parsers.parseSetOption('smoothscroll=yes')).to.throw(Error, 'Invalid argument');
+ it("throws error on unknown property", () => {
+ expect(() => parsers.parseSetOption("encoding=utf-8")).to.throw(
+ Error,
+ "Unknown"
+ );
+ expect(() => parsers.parseSetOption("paste")).to.throw(Error, "Unknown");
+ expect(() => parsers.parseSetOption("nopaste")).to.throw(
+ Error,
+ "Unknown"
+ );
+ expect(() => parsers.parseSetOption("smoothscroll=yes")).to.throw(
+ Error,
+ "Invalid argument"
+ );
});
});
});