michael@0: /* michael@0: * Copyright 2012, Mozilla Foundation and contributors michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: 'use strict'; michael@0: // michael@0: michael@0: // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT michael@0: // DO NOT EDIT IT DIRECTLY michael@0: michael@0: var exports = {}; michael@0: michael@0: var TEST_URI = "data:text/html;charset=utf-8,

gcli-testIncomplete.js

"; michael@0: michael@0: function test() { michael@0: return Task.spawn(function() { michael@0: let options = yield helpers.openTab(TEST_URI); michael@0: yield helpers.openToolbar(options); michael@0: gcli.addItems(mockCommands.items); michael@0: michael@0: yield helpers.runTests(options, exports); michael@0: michael@0: gcli.removeItems(mockCommands.items); michael@0: yield helpers.closeToolbar(options); michael@0: yield helpers.closeTab(options); michael@0: }).then(finish, helpers.handleError); michael@0: } michael@0: michael@0: // michael@0: michael@0: // var assert = require('../testharness/assert'); michael@0: // var helpers = require('./helpers'); michael@0: michael@0: exports.testBasic = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: setup: 'tsu 2 extra', michael@0: check: { michael@0: args: { michael@0: num: { value: 2, type: 'Argument' } michael@0: } michael@0: }, michael@0: post: function() { michael@0: var requisition = options.requisition; michael@0: michael@0: assert.is(requisition._unassigned.length, michael@0: 1, michael@0: 'single unassigned: tsu 2 extra'); michael@0: assert.is(requisition._unassigned[0].param.type.isIncompleteName, michael@0: false, michael@0: 'unassigned.isIncompleteName: tsu 2 extra'); michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tsu', michael@0: check: { michael@0: args: { michael@0: num: { value: undefined, type: 'BlankArgument' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tsg', michael@0: check: { michael@0: args: { michael@0: solo: { type: 'BlankArgument' }, michael@0: txt1: { type: 'BlankArgument' }, michael@0: bool: { type: 'BlankArgument' }, michael@0: txt2: { type: 'BlankArgument' }, michael@0: num: { type: 'BlankArgument' } michael@0: } michael@0: } michael@0: } michael@0: ]); michael@0: }; michael@0: michael@0: exports.testCompleted = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: setup: 'tsela', michael@0: check: { michael@0: args: { michael@0: command: { name: 'tselarr', type: 'Argument' }, michael@0: num: { type: 'BlankArgument' }, michael@0: arr: { type: 'ArrayArgument' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tsn dif ', michael@0: check: { michael@0: input: 'tsn dif ', michael@0: hints: '', michael@0: markup: 'VVVVVVVV', michael@0: cursor: 8, michael@0: status: 'ERROR', michael@0: args: { michael@0: command: { name: 'tsn dif', type: 'MergedArgument' }, michael@0: text: { type: 'BlankArgument', status: 'INCOMPLETE' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tsn di', michael@0: check: { michael@0: input: 'tsn dif ', michael@0: hints: '', michael@0: markup: 'VVVVVVVV', michael@0: cursor: 8, michael@0: status: 'ERROR', michael@0: args: { michael@0: command: { name: 'tsn dif', type: 'Argument' }, michael@0: text: { type: 'BlankArgument', status: 'INCOMPLETE' } michael@0: } michael@0: } michael@0: }, michael@0: // The above 2 tests take different routes to 'tsn dif '. michael@0: // The results should be similar. The difference is in args.command.type. michael@0: { michael@0: setup: 'tsg -', michael@0: check: { michael@0: input: 'tsg -', michael@0: hints: '-txt1 [options]', michael@0: markup: 'VVVVI', michael@0: cursor: 5, michael@0: status: 'ERROR', michael@0: args: { michael@0: solo: { value: undefined, status: 'INCOMPLETE' }, michael@0: txt1: { value: undefined, status: 'VALID' }, michael@0: bool: { value: false, status: 'VALID' }, michael@0: txt2: { value: undefined, status: 'VALID' }, michael@0: num: { value: undefined, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tsg -', michael@0: check: { michael@0: input: 'tsg --txt1 ', michael@0: hints: ' [options]', michael@0: markup: 'VVVVIIIIIIV', michael@0: cursor: 11, michael@0: status: 'ERROR', michael@0: args: { michael@0: solo: { value: undefined, status: 'INCOMPLETE' }, michael@0: txt1: { value: undefined, status: 'INCOMPLETE' }, michael@0: bool: { value: false, status: 'VALID' }, michael@0: txt2: { value: undefined, status: 'VALID' }, michael@0: num: { value: undefined, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tsg --txt1 fred', michael@0: check: { michael@0: input: 'tsg --txt1 fred', michael@0: hints: ' [options]', michael@0: markup: 'VVVVVVVVVVVVVVV', michael@0: status: 'ERROR', michael@0: args: { michael@0: solo: { value: undefined, status: 'INCOMPLETE' }, michael@0: txt1: { value: 'fred', status: 'VALID' }, michael@0: bool: { value: false, status: 'VALID' }, michael@0: txt2: { value: undefined, status: 'VALID' }, michael@0: num: { value: undefined, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tscook key value --path path --', michael@0: check: { michael@0: input: 'tscook key value --path path --', michael@0: hints: 'domain [options]', michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVII', michael@0: status: 'ERROR', michael@0: args: { michael@0: key: { value: 'key', status: 'VALID' }, michael@0: value: { value: 'value', status: 'VALID' }, michael@0: path: { value: 'path', status: 'VALID' }, michael@0: domain: { value: undefined, status: 'VALID' }, michael@0: secure: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tscook key value --path path --domain domain --', michael@0: check: { michael@0: input: 'tscook key value --path path --domain domain --', michael@0: hints: 'secure [options]', michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVII', michael@0: status: 'ERROR', michael@0: args: { michael@0: key: { value: 'key', status: 'VALID' }, michael@0: value: { value: 'value', status: 'VALID' }, michael@0: path: { value: 'path', status: 'VALID' }, michael@0: domain: { value: 'domain', status: 'VALID' }, michael@0: secure: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: } michael@0: ]); michael@0: michael@0: }; michael@0: michael@0: exports.testCase = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: setup: 'tsg AA', michael@0: check: { michael@0: input: 'tsg AA', michael@0: hints: ' [options] -> aaa', michael@0: markup: 'VVVVII', michael@0: status: 'ERROR', michael@0: args: { michael@0: solo: { value: undefined, text: 'AA', status: 'INCOMPLETE' }, michael@0: txt1: { value: undefined, status: 'VALID' }, michael@0: bool: { value: false, status: 'VALID' }, michael@0: txt2: { value: undefined, status: 'VALID' }, michael@0: num: { value: undefined, status: 'VALID' } michael@0: } michael@0: } michael@0: } michael@0: ]); michael@0: }; michael@0: michael@0: exports.testIncomplete = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: setup: 'tsm a a -', michael@0: check: { michael@0: args: { michael@0: abc: { value: 'a', type: 'Argument' }, michael@0: txt: { value: 'a', type: 'Argument' }, michael@0: num: { value: undefined, arg: ' -', type: 'Argument', status: 'INCOMPLETE' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tsg -', michael@0: check: { michael@0: args: { michael@0: solo: { type: 'BlankArgument' }, michael@0: txt1: { type: 'BlankArgument' }, michael@0: bool: { type: 'BlankArgument' }, michael@0: txt2: { type: 'BlankArgument' }, michael@0: num: { type: 'BlankArgument' } michael@0: } michael@0: }, michael@0: post: function() { michael@0: var requisition = options.requisition; michael@0: michael@0: assert.is(requisition._unassigned[0], michael@0: requisition.getAssignmentAt(5), michael@0: 'unassigned -'); michael@0: assert.is(requisition._unassigned.length, michael@0: 1, michael@0: 'single unassigned - tsg -'); michael@0: assert.is(requisition._unassigned[0].param.type.isIncompleteName, michael@0: true, michael@0: 'unassigned.isIncompleteName: tsg -'); michael@0: } michael@0: } michael@0: ]); michael@0: }; michael@0: michael@0: exports.testRepeated = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: setup: 'tscook key value --path jjj --path kkk', michael@0: check: { michael@0: input: 'tscook key value --path jjj --path kkk', michael@0: hints: ' [options]', michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVEEEEEEVEEE', michael@0: cursor: 38, michael@0: current: '__unassigned', michael@0: status: 'ERROR', michael@0: options: [ ], michael@0: message: '', michael@0: predictions: [ ], michael@0: unassigned: [ ' --path', ' kkk' ], michael@0: args: { michael@0: command: { name: 'tscook' }, michael@0: key: { michael@0: value: 'key', michael@0: arg: ' key', michael@0: status: 'VALID', michael@0: message: '' michael@0: }, michael@0: value: { michael@0: value: 'value', michael@0: arg: ' value', michael@0: status: 'VALID', michael@0: message: '' michael@0: }, michael@0: path: { michael@0: value: 'jjj', michael@0: arg: ' --path jjj', michael@0: status: 'VALID', michael@0: message: '' michael@0: }, michael@0: domain: { michael@0: value: undefined, michael@0: arg: '', michael@0: status: 'VALID', michael@0: message: '' michael@0: }, michael@0: secure: { michael@0: value: false, michael@0: arg: '', michael@0: status: 'VALID', michael@0: message: '' michael@0: }, michael@0: } michael@0: } michael@0: } michael@0: ]); michael@0: }; michael@0: michael@0: exports.testHidden = function(options) { michael@0: return helpers.audit(options, [ michael@0: { michael@0: setup: 'tshidde', michael@0: check: { michael@0: input: 'tshidde', michael@0: hints: ' -> tse', michael@0: status: 'ERROR' michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tshidden', michael@0: check: { michael@0: input: 'tshidden', michael@0: hints: ' [options]', michael@0: markup: 'VVVVVVVV', michael@0: status: 'VALID', michael@0: args: { michael@0: visible: { value: undefined, status: 'VALID' }, michael@0: invisiblestring: { value: undefined, status: 'VALID' }, michael@0: invisibleboolean: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tshidden --vis', michael@0: check: { michael@0: input: 'tshidden --vis', michael@0: hints: 'ible [options]', michael@0: markup: 'VVVVVVVVVIIIII', michael@0: status: 'ERROR', michael@0: args: { michael@0: visible: { value: undefined, status: 'VALID' }, michael@0: invisiblestring: { value: undefined, status: 'VALID' }, michael@0: invisibleboolean: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tshidden --invisiblestrin', michael@0: check: { michael@0: input: 'tshidden --invisiblestrin', michael@0: hints: ' [options]', michael@0: markup: 'VVVVVVVVVEEEEEEEEEEEEEEEE', michael@0: status: 'ERROR', michael@0: args: { michael@0: visible: { value: undefined, status: 'VALID' }, michael@0: invisiblestring: { value: undefined, status: 'VALID' }, michael@0: invisibleboolean: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tshidden --invisiblestring', michael@0: check: { michael@0: input: 'tshidden --invisiblestring', michael@0: hints: ' [options]', michael@0: markup: 'VVVVVVVVVIIIIIIIIIIIIIIIII', michael@0: status: 'ERROR', michael@0: args: { michael@0: visible: { value: undefined, status: 'VALID' }, michael@0: invisiblestring: { value: undefined, status: 'INCOMPLETE' }, michael@0: invisibleboolean: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tshidden --invisiblestring x', michael@0: check: { michael@0: input: 'tshidden --invisiblestring x', michael@0: hints: ' [options]', michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: { michael@0: visible: { value: undefined, status: 'VALID' }, michael@0: invisiblestring: { value: 'x', status: 'VALID' }, michael@0: invisibleboolean: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tshidden --invisibleboolea', michael@0: check: { michael@0: input: 'tshidden --invisibleboolea', michael@0: hints: ' [options]', michael@0: markup: 'VVVVVVVVVEEEEEEEEEEEEEEEEE', michael@0: status: 'ERROR', michael@0: args: { michael@0: visible: { value: undefined, status: 'VALID' }, michael@0: invisiblestring: { value: undefined, status: 'VALID' }, michael@0: invisibleboolean: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tshidden --invisibleboolean', michael@0: check: { michael@0: input: 'tshidden --invisibleboolean', michael@0: hints: ' [options]', michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: args: { michael@0: visible: { value: undefined, status: 'VALID' }, michael@0: invisiblestring: { value: undefined, status: 'VALID' }, michael@0: invisibleboolean: { value: true, status: 'VALID' } michael@0: } michael@0: } michael@0: }, michael@0: { michael@0: setup: 'tshidden --visible xxx', michael@0: check: { michael@0: input: 'tshidden --visible xxx', michael@0: markup: 'VVVVVVVVVVVVVVVVVVVVVV', michael@0: status: 'VALID', michael@0: hints: '', michael@0: args: { michael@0: visible: { value: 'xxx', status: 'VALID' }, michael@0: invisiblestring: { value: undefined, status: 'VALID' }, michael@0: invisibleboolean: { value: false, status: 'VALID' } michael@0: } michael@0: } michael@0: } michael@0: ]); michael@0: };