browser_gcli_union.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Copyright 2012, Mozilla Foundation and contributors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. "use strict";
  17. // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
  18. // PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
  19. const exports = {};
  20. function test() {
  21. helpers.runTestModule(exports, "browser_gcli_union.js");
  22. }
  23. // var assert = require('../testharness/assert');
  24. // var helpers = require('./helpers');
  25. exports.testDefault = function (options) {
  26. return helpers.audit(options, [
  27. {
  28. setup: "unionc1",
  29. check: {
  30. input: "unionc1",
  31. markup: "VVVVVVV",
  32. hints: " <first>",
  33. status: "ERROR",
  34. args: {
  35. first: {
  36. value: undefined,
  37. arg: "",
  38. status: "INCOMPLETE"
  39. }
  40. }
  41. }
  42. },
  43. {
  44. setup: "unionc1 three",
  45. check: {
  46. input: "unionc1 three",
  47. markup: "VVVVVVVVVVVVV",
  48. hints: "",
  49. status: "VALID",
  50. args: {
  51. first: {
  52. value: function (data) {
  53. assert.is(Object.keys(data).length, 2, "union3 Object.keys");
  54. assert.is(data.type, "string", "union3 val type");
  55. assert.is(data.string, "three", "union3 val string");
  56. },
  57. arg: " three",
  58. status: "VALID"
  59. }
  60. }
  61. },
  62. exec: {
  63. output: [
  64. /"type": ?"string"/,
  65. /"string": ?"three"/
  66. ]
  67. },
  68. post: function (output, text) {
  69. var data = output.data.first;
  70. assert.is(Object.keys(data).length, 2, "union3 Object.keys");
  71. assert.is(data.type, "string", "union3 val type");
  72. assert.is(data.string, "three", "union3 val string");
  73. }
  74. },
  75. {
  76. setup: "unionc1 one",
  77. check: {
  78. input: "unionc1 one",
  79. markup: "VVVVVVVVVVV",
  80. hints: "",
  81. status: "VALID",
  82. args: {
  83. first: {
  84. value: function (data) {
  85. assert.is(Object.keys(data).length, 2, "union1 Object.keys");
  86. assert.is(data.type, "selection", "union1 val type");
  87. assert.is(data.selection, 1, "union1 val selection");
  88. },
  89. arg: " one",
  90. status: "VALID"
  91. }
  92. }
  93. },
  94. exec: {
  95. output: [
  96. /"type": ?"selection"/,
  97. /"selection": ?1/
  98. ]
  99. },
  100. post: function (output, text) {
  101. var data = output.data.first;
  102. assert.is(Object.keys(data).length, 2, "union1 Object.keys");
  103. assert.is(data.type, "selection", "union1 val type");
  104. assert.is(data.selection, 1, "union1 val selection");
  105. }
  106. },
  107. {
  108. skipIf: options.isPhantomjs, // PhantomJS gets predictions wrong
  109. setup: "unionc1 5",
  110. check: {
  111. input: "unionc1 5",
  112. markup: "VVVVVVVVV",
  113. hints: " -> two",
  114. predictions: [ "two" ],
  115. status: "VALID",
  116. args: {
  117. first: {
  118. value: function (data) {
  119. assert.is(Object.keys(data).length, 2, "union5 Object.keys");
  120. assert.is(data.type, "number", "union5 val type");
  121. assert.is(data.number, 5, "union5 val number");
  122. },
  123. arg: " 5",
  124. status: "VALID"
  125. }
  126. }
  127. },
  128. exec: {
  129. output: [
  130. /"type": ?"number"/,
  131. /"number": ?5/
  132. ]
  133. },
  134. post: function (output, text) {
  135. var data = output.data.first;
  136. assert.is(Object.keys(data).length, 2, "union5 Object.keys");
  137. assert.is(data.type, "number", "union5 val type");
  138. assert.is(data.number, 5, "union5 val number");
  139. }
  140. },
  141. {
  142. skipIf: options.isPhantomjs, // PhantomJS URL type is broken
  143. setup: "unionc2 on",
  144. check: {
  145. input: "unionc2 on",
  146. hints: "e",
  147. markup: "VVVVVVVVII",
  148. current: "first",
  149. status: "ERROR",
  150. predictionsContains: [
  151. "one",
  152. "http://on/",
  153. "https://on/"
  154. ],
  155. args: {
  156. command: { name: "unionc2" },
  157. first: {
  158. value: undefined,
  159. arg: " on",
  160. status: "INCOMPLETE",
  161. message: "Can\u2019t use \u2018on\u2019."
  162. },
  163. }
  164. }
  165. }
  166. ]);
  167. };