mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 00:17:57 +01:00
Fix some option validators. Add tests.
This commit is contained in:
@@ -633,12 +633,12 @@ var Bookmarks = Module("bookmarks", {
|
||||
};
|
||||
|
||||
completion.searchEngine = function searchEngine(context, suggest) {
|
||||
let engines = services.browserSearch.getEngines({});
|
||||
if (suggest)
|
||||
engines = engines.filter(function (e) e.supportsResponseType("application/x-suggestions+json"));
|
||||
|
||||
context.title = ["Suggest Engine", "Description"];
|
||||
context.completions = engines.map(function (e) [e.alias, e.description]);
|
||||
context.keys = { text: "keyword", description: "title", icon: "icon" };
|
||||
context.completions = values(bookmarks.searchEngines);
|
||||
if (suggest)
|
||||
context.filters.push(function ({ item }) item.supportsResponseType("application/x-suggestions+json"));
|
||||
|
||||
};
|
||||
|
||||
completion.searchEngineSuggest = function searchEngineSuggest(context, engineAliases, kludge) {
|
||||
|
||||
@@ -1047,7 +1047,7 @@ var Completion = Module("completion", {
|
||||
options.add(["complete", "cpt"],
|
||||
"Items which are completed at the :open prompts",
|
||||
"charlist", config.defaults.complete == null ? "slf" : config.defaults.complete,
|
||||
{ get values() values(completion.urlCompleters) });
|
||||
{ get values() values(completion.urlCompleters).toArray() });
|
||||
|
||||
options.add(["wildanchor", "wia"],
|
||||
"Define which completion groups only match at the beginning of their text",
|
||||
|
||||
@@ -1036,7 +1036,7 @@ unlet s:cpo_save
|
||||
});
|
||||
},
|
||||
options: function (dactyl, modules, window) {
|
||||
const { options } = modules;
|
||||
const { completion, options } = modules;
|
||||
|
||||
var shell, shellcmdflag;
|
||||
if (util.OS.isWindows) {
|
||||
|
||||
@@ -387,6 +387,33 @@ Controller.prototype = {
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Triggers a completion function with the given arguments an
|
||||
* ensures that no errors have occurred during the process.
|
||||
*
|
||||
* @param {object} self The 'this' object for which to trigger the
|
||||
* completer.
|
||||
* @param {function|string} func The method or method name to call.
|
||||
* @param {string} string The method or method name to call. @optional
|
||||
* @param {string} message The message to display upon assertion failure. @optional
|
||||
* @param {...} Extra arguments are passed to the completion
|
||||
* function directly.
|
||||
*/
|
||||
testCompleter: wrapAssertNoErrors(function testCompleter(self, func, string, message) {
|
||||
var context = this.modules.CompletionContext(string || "");
|
||||
context.tabPressed = true;
|
||||
context.forkapply("completions", 0, self, func, Array.slice(arguments, testCompleter.length));
|
||||
|
||||
utils.assert("dactyl.runCompletions", context.wait(5000),
|
||||
message || "Completion failed: " + self + "." + func);
|
||||
|
||||
for (var [, ctxt] in Iterator(context.contextList))
|
||||
for (var [, item] in Iterator(ctxt.items))
|
||||
ctxt.createRow(item);
|
||||
|
||||
return context;
|
||||
}),
|
||||
|
||||
/**
|
||||
* Triggers Ex completion for the given command string and ensures
|
||||
* that no errors have occurred during the process.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
var utils = require("utils");
|
||||
const { module } = utils;
|
||||
|
||||
var dactyllib = module("dactyl");
|
||||
var jumlib = module("resource://mozmill/modules/jum.js");
|
||||
|
||||
@@ -637,7 +636,9 @@ var tests = {
|
||||
["Navigation Toolbar", toolbarState("#nav-bar", false)],
|
||||
["Bookmarks Toolbar", toolbarState("#PersonalToolbar", false)],
|
||||
["Navigation Toolbar", toolbarState("#nav-bar", true)],
|
||||
["Bookmarks Toolbar", toolbarState("#PersonalToolbar", true)]
|
||||
["Bookmarks Toolbar", toolbarState("#PersonalToolbar", true)],
|
||||
["Navigation Toolbar", toolbarState("#nav-bar", false)],
|
||||
["Bookmarks Toolbar", toolbarState("#PersonalToolbar", false)]
|
||||
],
|
||||
error: ["", "foo"]
|
||||
},
|
||||
|
||||
40
common/tests/functional/testOptions.js
Normal file
40
common/tests/functional/testOptions.js
Normal file
@@ -0,0 +1,40 @@
|
||||
// Runs a slew of generic option tests
|
||||
|
||||
var utils = require("utils");
|
||||
const { module } = utils;
|
||||
|
||||
var dactyllib = module("dactyl");
|
||||
var jumlib = module("resource://mozmill/modules/jum.js");
|
||||
|
||||
var setupModule = function (module) {
|
||||
controller = mozmill.getBrowserController();
|
||||
dactyl = new dactyllib.Controller(controller);
|
||||
};
|
||||
var teardownModule = function (module) {
|
||||
dactyl.teardown();
|
||||
}
|
||||
|
||||
function $(selector) controller.window.document.querySelector(selector);
|
||||
|
||||
function testDefaultValidators() {
|
||||
for (var option in dactyl.modules.options)
|
||||
dactyl.assertNoErrors(function () {
|
||||
dactyl.assertNoErrorMessages(function () {
|
||||
dump("OPT VAL " + option.name + "\n");
|
||||
utils.assert("testOptions.testValidators", option.validator(option.value),
|
||||
"Option '" + option.name + "' validator failed");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var options = {};
|
||||
|
||||
function testCompleters() {
|
||||
for (var option in dactyl.modules.options)
|
||||
for (var [,value] in Iterator([""].concat(options[option.name] || []))) {
|
||||
dump("OPT COMP " + option.name + " " + value + "\n");
|
||||
dactyl.testCompleter(option, "completer", value, "Option '" + option.name + "' completer failed");
|
||||
}
|
||||
}
|
||||
|
||||
// vim: sw=4 ts=8 et:
|
||||
Reference in New Issue
Block a user