mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-17 14:25:45 +01:00
Fix some option validators. Add tests.
This commit is contained in:
@@ -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