summaryrefslogtreecommitdiffstats
path: root/devtools/client/commandline/test/browser_gcli_union.js
blob: cff9395b412c88fe9ef10cd59c8c808582cf9e5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Copyright 2012, Mozilla Foundation and contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

"use strict";

// THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
// PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT

const exports = {};

function test() {
  helpers.runTestModule(exports, "browser_gcli_union.js");
}

// var assert = require('../testharness/assert');
// var helpers = require('./helpers');

exports.testDefault = function (options) {
  return helpers.audit(options, [
    {
      setup:    "unionc1",
      check: {
        input:  "unionc1",
        markup: "VVVVVVV",
        hints:         " <first>",
        status: "ERROR",
        args: {
          first: {
            value: undefined,
            arg: "",
            status: "INCOMPLETE"
          }
        }
      }
    },
    {
      setup:    "unionc1 three",
      check: {
        input:  "unionc1 three",
        markup: "VVVVVVVVVVVVV",
        hints:               "",
        status: "VALID",
        args: {
          first: {
            value: function (data) {
              assert.is(Object.keys(data).length, 2, "union3 Object.keys");
              assert.is(data.type, "string", "union3 val type");
              assert.is(data.string, "three", "union3 val string");
            },
            arg: " three",
            status: "VALID"
          }
        }
      },
      exec: {
        output: [
          /"type": ?"string"/,
          /"string": ?"three"/
        ]
      },
      post: function (output, text) {
        var data = output.data.first;
        assert.is(Object.keys(data).length, 2, "union3 Object.keys");
        assert.is(data.type, "string", "union3 val type");
        assert.is(data.string, "three", "union3 val string");
      }
    },
    {
      setup:    "unionc1 one",
      check: {
        input:  "unionc1 one",
        markup: "VVVVVVVVVVV",
        hints:             "",
        status: "VALID",
        args: {
          first: {
            value: function (data) {
              assert.is(Object.keys(data).length, 2, "union1 Object.keys");
              assert.is(data.type, "selection", "union1 val type");
              assert.is(data.selection, 1, "union1 val selection");
            },
            arg: " one",
            status: "VALID"
          }
        }
      },
      exec: {
        output: [
          /"type": ?"selection"/,
          /"selection": ?1/
        ]
      },
      post: function (output, text) {
        var data = output.data.first;
        assert.is(Object.keys(data).length, 2, "union1 Object.keys");
        assert.is(data.type, "selection", "union1 val type");
        assert.is(data.selection, 1, "union1 val selection");
      }
    },
    {
      skipIf: options.isPhantomjs, // PhantomJS gets predictions wrong
      setup:    "unionc1 5",
      check: {
        input:  "unionc1 5",
        markup: "VVVVVVVVV",
        hints:           " -> two",
        predictions: [ "two" ],
        status: "VALID",
        args: {
          first: {
            value: function (data) {
              assert.is(Object.keys(data).length, 2, "union5 Object.keys");
              assert.is(data.type, "number", "union5 val type");
              assert.is(data.number, 5, "union5 val number");
            },
            arg: " 5",
            status: "VALID"
          }
        }
      },
      exec: {
        output: [
          /"type": ?"number"/,
          /"number": ?5/
        ]
      },
      post: function (output, text) {
        var data = output.data.first;
        assert.is(Object.keys(data).length, 2, "union5 Object.keys");
        assert.is(data.type, "number", "union5 val type");
        assert.is(data.number, 5, "union5 val number");
      }
    },
    {
      skipIf: options.isPhantomjs, // PhantomJS URL type is broken
      setup:    "unionc2 on",
      check: {
        input:  "unionc2 on",
        hints:            "e",
        markup: "VVVVVVVVII",
        current: "first",
        status: "ERROR",
        predictionsContains: [
          "one",
          "http://on/",
          "https://on/"
        ],
        args: {
          command: { name: "unionc2" },
          first: {
            value: undefined,
            arg: " on",
            status: "INCOMPLETE",
            message: "Can\u2019t use \u2018on\u2019."
          },
        }
      }
    }
  ]);
};