aboutsummaryrefslogtreecommitdiff
path: root/e2e/options_form.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'e2e/options_form.test.ts')
-rw-r--r--e2e/options_form.test.ts107
1 files changed, 58 insertions, 49 deletions
diff --git a/e2e/options_form.test.ts b/e2e/options_form.test.ts
index 2121348..bb5ebf1 100644
--- a/e2e/options_form.test.ts
+++ b/e2e/options_form.test.ts
@@ -1,17 +1,16 @@
-import * as path from 'path';
-import * as assert from 'assert';
+import * as path from "path";
+import * as assert from "assert";
-import { Builder, Lanthan } from 'lanthan';
-import OptionPage from './lib/OptionPage';
+import { Builder, Lanthan } from "lanthan";
+import OptionPage from "./lib/OptionPage";
describe("options form page", () => {
let lanthan: Lanthan;
let browser: any;
- beforeEach(async() => {
- lanthan = await Builder
- .forBrowser('firefox')
- .spyAddon(path.join(__dirname, '..'))
+ beforeEach(async () => {
+ lanthan = await Builder.forBrowser("firefox")
+ .spyAddon(path.join(__dirname, ".."))
.build();
browser = lanthan.getWebExtBrowser();
@@ -21,109 +20,119 @@ describe("options form page", () => {
}
});
- afterEach(async() => {
+ afterEach(async () => {
if (lanthan) {
await lanthan.quit();
}
});
- it('switch to form settings', async () => {
+ it("switch to form settings", async () => {
const page = await OptionPage.open(lanthan);
await page.switchToForm();
- const { settings } = await browser.storage.local.get('settings');
- assert.strictEqual(settings.source, 'form')
+ const { settings } = await browser.storage.local.get("settings");
+ assert.strictEqual(settings.source, "form");
});
- it('add blacklist item', async () => {
+ it("add blacklist item", async () => {
const page = await OptionPage.open(lanthan);
const forms = await page.switchToForm();
// assert default
- let settings = (await browser.storage.local.get('settings')).settings;
+ let settings = (await browser.storage.local.get("settings")).settings;
assert.deepStrictEqual(settings.form.blacklist, []);
// add blacklist items
await forms.addBlacklist();
- await forms.setBlacklist(0, 'google.com');
+ await forms.setBlacklist(0, "google.com");
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepStrictEqual(settings.form.blacklist, ['google.com']);
+ settings = (await browser.storage.local.get("settings")).settings;
+ assert.deepStrictEqual(settings.form.blacklist, ["google.com"]);
await forms.addBlacklist();
- await forms.setBlacklist(1, 'yahoo.com');
+ await forms.setBlacklist(1, "yahoo.com");
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepStrictEqual(settings.form.blacklist, ['google.com', 'yahoo.com']);
+ settings = (await browser.storage.local.get("settings")).settings;
+ assert.deepStrictEqual(settings.form.blacklist, [
+ "google.com",
+ "yahoo.com",
+ ]);
// delete first item
await forms.removeBlackList(0);
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepStrictEqual(settings.form.blacklist, ['yahoo.com'])
+ settings = (await browser.storage.local.get("settings")).settings;
+ assert.deepStrictEqual(settings.form.blacklist, ["yahoo.com"]);
});
- it('add a partial blacklist item', async () => {
+ it("add a partial blacklist item", async () => {
const page = await OptionPage.open(lanthan);
const forms = await page.switchToForm();
// assert default
- let settings = (await browser.storage.local.get('settings')).settings;
+ let settings = (await browser.storage.local.get("settings")).settings;
assert.deepStrictEqual(settings.form.blacklist, []);
// add blacklist items
await forms.addPartialBlacklist();
- await forms.setPartialBlacklist(0, 'google.com', 'j,k,<C-U>');
+ await forms.setPartialBlacklist(0, "google.com", "j,k,<C-U>");
- settings = (await browser.storage.local.get('settings')).settings;
+ settings = (await browser.storage.local.get("settings")).settings;
assert.deepStrictEqual(settings.form.blacklist, [
- { url: 'google.com', keys: ['j', 'k', '<C-U>'] },
+ { url: "google.com", keys: ["j", "k", "<C-U>"] },
]);
await forms.addPartialBlacklist();
- await forms.setPartialBlacklist(1, 'yahoo.com', 'g,G');
+ await forms.setPartialBlacklist(1, "yahoo.com", "g,G");
- settings = (await browser.storage.local.get('settings')).settings;
+ settings = (await browser.storage.local.get("settings")).settings;
assert.deepStrictEqual(settings.form.blacklist, [
- { url: 'google.com', keys: ['j', 'k', '<C-U>'] },
- { url: 'yahoo.com', keys: ['g', 'G'] },
+ { url: "google.com", keys: ["j", "k", "<C-U>"] },
+ { url: "yahoo.com", keys: ["g", "G"] },
]);
await forms.addBlacklist();
- await forms.setBlacklist(0, 'bing.com');
+ await forms.setBlacklist(0, "bing.com");
- settings = (await browser.storage.local.get('settings')).settings;
+ settings = (await browser.storage.local.get("settings")).settings;
assert.deepStrictEqual(settings.form.blacklist, [
- { url: 'google.com', keys: ['j', 'k', '<C-U>'] },
- { url: 'yahoo.com', keys: ['g', 'G'] },
- 'bing.com',
+ { url: "google.com", keys: ["j", "k", "<C-U>"] },
+ { url: "yahoo.com", keys: ["g", "G"] },
+ "bing.com",
]);
// delete first item
await forms.removePartialBlackList(0);
- settings = (await browser.storage.local.get('settings')).settings;
+ settings = (await browser.storage.local.get("settings")).settings;
assert.deepStrictEqual(settings.form.blacklist, [
- { url: 'yahoo.com', keys: ['g', 'G'] },
- 'bing.com',
- ])
+ { url: "yahoo.com", keys: ["g", "G"] },
+ "bing.com",
+ ]);
});
- it('add search engines', async () => {
+ it("add search engines", async () => {
const page = await OptionPage.open(lanthan);
const forms = await page.switchToForm();
// assert default
- let settings = (await browser.storage.local.get('settings')).settings;
- assert.deepStrictEqual(settings.form.search.default, 'google');
+ let settings = (await browser.storage.local.get("settings")).settings;
+ assert.deepStrictEqual(settings.form.search.default, "google");
// change default
await forms.setDefaultSearchEngine(2);
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepStrictEqual(settings.form.search.default, 'bing');
+ settings = (await browser.storage.local.get("settings")).settings;
+ assert.deepStrictEqual(settings.form.search.default, "bing");
await forms.addSearchEngine();
- await forms.setSearchEngine(6, 'yippy', 'https://www.yippy.com/search?query={}');
-
- settings = (await browser.storage.local.get('settings')).settings;
- assert.deepStrictEqual(settings.form.search.engines[6], ['yippy', 'https://www.yippy.com/search?query={}']);
+ await forms.setSearchEngine(
+ 6,
+ "yippy",
+ "https://www.yippy.com/search?query={}"
+ );
+
+ settings = (await browser.storage.local.get("settings")).settings;
+ assert.deepStrictEqual(settings.form.search.engines[6], [
+ "yippy",
+ "https://www.yippy.com/search?query={}",
+ ]);
});
});