]> git.donarmstrong.com Git - dactyl.git/blob - common/tests/functional/testEchoCommands.js
Initial import of 1.0~b6
[dactyl.git] / common / tests / functional / testEchoCommands.js
1 var dactyllib = require("utils").module("dactyl");
2
3 var setupModule = function (module) {
4     controller = mozmill.getBrowserController();
5     dactyl = new dactyllib.Controller(controller);
6 };
7
8 var teardownModule = function (module) {
9     dactyl.teardown();
10 }
11
12 var teardownTest = function (test) {
13     dactyl.closeMessageWindow();
14 };
15
16 var testEchoCommand_SingleLineMessageAndClosedMOW_MessageDisplayedInMessageLine = function () {
17     const output = "foobar";
18
19     assertEchoGeneratesLineOutput({
20         ECHO_COMMAND: "echo " + output.quote(),
21         EXPECTED_OUTPUT: output
22     });
23 };
24
25 var testEchoCommand_SingleLineMessageAndOpenMOW_MessageAppendedToMOW = function () {
26     const output = "foobar";
27
28     dactyl.openMessageWindow();
29
30     assertEchoGeneratesWindowOutput({
31         ECHO_COMMAND: "echo " + output.quote(),
32         EXPECTED_OUTPUT: RegExp(output)
33     });
34 };
35
36 var testEchoCommand_MultilineMessageAndClosedMOW_MessageDisplayedInMOW = function () {
37     const output = "foo\nbar";
38
39     assertEchoGeneratesWindowOutput({
40         ECHO_COMMAND: "echo " + output.quote(),
41         EXPECTED_OUTPUT: output
42     });
43 };
44
45 var testEchoCommand_MultilineMessageAndOpenMOW_MessageAppendedToMOW = function () {
46     const output = "foo\nbar";
47
48     dactyl.openMessageWindow();
49
50     assertEchoGeneratesWindowOutput({
51         ECHO_COMMAND: "echo " + output.quote(),
52         EXPECTED_OUTPUT: RegExp(output)
53     });
54 };
55
56 var testEchoCommand_ObjectArgumentAndClosedMOW_MessageDisplayedInMOW = function () {
57     assertEchoGeneratesWindowOutput({
58         ECHO_COMMAND: "echo var obj = { x: 1, y: 2 }; obj;",
59         EXPECTED_OUTPUT: "[object\u00A0Object]::\nx: 1\ny: 2\n"
60     });
61 };
62
63 function executeCommand(command) {
64     dactyl.runViCommand(":" + command);
65     dactyl.runViCommand([["VK_RETURN"]]);
66 }
67
68 function assertEchoGeneratesWindowOutput({ ECHO_COMMAND, EXPECTED_OUTPUT }) {
69     executeCommand(ECHO_COMMAND);
70     dactyl.assertMessageWindow(EXPECTED_OUTPUT);
71 }
72
73 function assertEchoGeneratesLineOutput({ ECHO_COMMAND, EXPECTED_OUTPUT }) {
74     executeCommand(ECHO_COMMAND);
75     dactyl.assertMessageLine(EXPECTED_OUTPUT);
76 }
77
78 // vim: sw=4 ts=8 et: