1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-05 23:34:10 +01:00

Bang on tests some more.

This commit is contained in:
Kris Maglione
2011-02-02 19:02:04 -05:00
parent a2ea607fcd
commit 2e91c2a3cb

View File

@@ -19,11 +19,19 @@ var teardownModule = function (module) {
dactyl.teardown(); dactyl.teardown();
} }
function hasNItems(nItems) function (context) context.allItems.items.length == nItems; function $(selector) controller.window.document.querySelector(selector);
function hasNItems(nItems) function (context) utils.assertEqual("testCommand.hasNItems", nItems, context.allItems.items.length);
function hasItems(context) context.allItems.items.length; function hasItems(context) context.allItems.items.length;
function hasntNullItems(context) hasItems(context) && function hasntNullItems(context) hasItems(context) &&
!context.allItems.items.some(function ({ text, description }) [text, description].some(function (text) /^\[object/.test(text))); !context.allItems.items.some(function ({ text, description }) [text, description].some(function (text) /^\[object/.test(text)));
function sidebarState(state)
function () typeof state == "string" ? $("#sidebar-title").value == state
: $("#sidebar-box").hidden == state;
var tests = { var tests = {
"!": { "!": {
multiOutput: ["echo foo"] multiOutput: ["echo foo"]
@@ -480,16 +488,24 @@ var tests = {
get setlocal() this.set, get setlocal() this.set,
sidebar: { sidebar: {
error: ["!", ""], error: ["!", ""],
noOutput: [ test: function (name) [
"! Add-ons", "Add-ons", "! Add-ons", ["! " + name, sidebarState(name)],
"! Bookmarks", "Bookmarks", "! Bookmarks", [name, sidebarState(name)],
"! Console", "Console", "! Console", ["! " + name, sidebarState(false)]
"! Downloads", "Downloads", "! Downloads",
"! History", "History", "! History",
"! Preferences", "Preferences", "! Preferences",
// "!" Previous sidebar isn't saved until the window loads.
// We don't give it enough time.
], ],
get noOutput()
Array.concat.apply([],
["Add-ons", // Final "! Add-ons" currently failing
"Bookmarks",
"Downloads",
"Console",
"History",
"Preferences"]
.map(this.test))
.concat([
["!", sidebarState("Preferences")],
["!", sidebarState(false)]
]),
completions: [ completions: [
["", hasntNullItems], ["", hasntNullItems],
"! " "! "
@@ -518,10 +534,15 @@ var tests = {
"./.pentadactyl/some-nonexistent/bad.js", "./.pentadactyl/some-nonexistent/bad.js",
"./.pentadactyl/some-nonexistent/bad.penta", "./.pentadactyl/some-nonexistent/bad.penta",
".pentadactyl/some-nonexistent/bad.js", ".pentadactyl/some-nonexistent/bad.js",
".pentadactyl/some-nonexistent/bad.penta" ".pentadactyl/some-nonexistent/bad.penta",
".pentadactyl/some-nonexistent-file.js"
], ],
singleOutput: [".pentadactyl/some-nonexistent-file.js"], completions: [
completions: this.runtime.completions ["", hasItems],
[".pentadactyl/some-nonexistent/", hasItems],
["chrome://browser/content/", hasItems],
["resource://dactyl/", hasItems]
]
}), }),
stop: { noOutput: [""] }, stop: { noOutput: [""] },
stopall: { noOutput: [""] }, stopall: { noOutput: [""] },
@@ -547,12 +568,12 @@ var tests = {
styledisable: { styledisable: {
init: ["style -n foo http:* div {}", "style -n bar ftp:* div", "styledisable -n bar"], init: ["style -n foo http:* div {}", "style -n bar ftp:* div", "styledisable -n bar"],
cleanup: ["delstyle -n foo", "delstyle -n bar"], cleanup: ["delstyle -n foo", "delstyle -n bar"],
noOutput: ["-name=foo"],
completions: [ completions: [
["", hasItems], ["", hasItems],
["-name=", hasNItems(1)], ["-name=", hasNItems(1)],
["-index=", hasNItems(1)] ["-index=", hasNItems(1)]
] ],
noOutput: ["-name=foo", "-name=bar"]
}, },
get styleenable() this.styledisable, get styleenable() this.styledisable,
styletoggle: { styletoggle: {
@@ -653,13 +674,13 @@ for (var val in Iterator(tests)) (function ([command, paramsList]) {
runCommands(command, testName, commands, function (cmd, test) { runCommands(command, testName, commands, function (cmd, test) {
var res = dactyl.assertMessage(function (msg) !msg, "Unexpected command output: " + cmd); var res = dactyl.assertMessage(function (msg) !msg, "Unexpected command output: " + cmd);
if (res && test) if (res && test)
jumlib.assert(test(), "Initializing for " + cmdName + " tests failed: " + cmd.quote() + " " + test); dactyl.assertMessage(test, "Running " + testName + " tests failed: " + cmd.quote() + " " + test.toSource());
}); });
break; break;
case "anyOutput": case "anyOutput":
runCommands(command, testName, commands, function (cmd, test) { runCommands(command, testName, commands, function (cmd, test) {
if (test) if (test)
jumlib.assert(test(), "Initializing for " + cmdName + " tests failed: " + cmd.quote() + " " + test); dactyl.assertMessage(test, "Running " + testName + " tests failed: " + cmd.quote() + " " + test.toSource());
}); });
break; break;
case "someOutput": case "someOutput":