How to use setup method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

test_pubsub_3_1.js

Source:test_pubsub_3_1.js Github

copy

Full Screen

1/*******************************************************************************2 * test_pubsub_3_1.js:3 * Component of the DOH-based test suite for the OpenAjax Hub.4 *5 * JavaScript logic for the unit test for routines having to do with managing event6 * publishing and event subscribing. (The "event hub" or "topic bus".)7 * [ This is a port of the Hub 1.0 testcases found in _TestPubSub.js. ]8 *9 * Copyright 2008 OpenAjax Alliance10 *11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 12 * use this file except in compliance with the License. You may obtain a copy 13 * of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless 14 * required by applicable law or agreed to in writing, software distributed 15 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 16 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations under the License.18 *19 ******************************************************************************/20/***********************************************************************21 * js3_122 **********************************************************************/23var js3_1 = {};24js3_1_0 = {};25js3_1_1 = {};26js3_1_2 = {};27js3_1_3 = {};28js3_1_4 = {};29js3_1_5 = {};30js3_1_6 = {};31js3_1_7 = {};32js3_1_8 = {};33//////////////////////////////////////////////////////34js3_1_0.run = function(scriptnum) {35 js3_1_0.scriptnum = scriptnum;36 js3_1_0.subscribe = {};37 js3_1_0.setup = {};38 js3_1_0.fire = {};39 js3_1_0.check = {};40 // In callback for topic X, publish on topic X 41 this.hubClient.subscribe("pub.same", js3_1.cbPubSame, this, function( subscriptionID, success, errCode ) {42 js3_1_0.do_setup.call(this, "_trigger");43 }, "_trigger");44}45js3_1.cbPubSame = function(subject, message, subscriberData) {46 if(message.step == "setup") {47 js3_1_0.do_fire.call(this, subscriberData);48 } else if(message.step == "fire") { 49 js3_1_0.do_check.call(this, subscriberData);50 } else if(message.step == "check") {51 js3_1_0.do_finish.call(this, subscriberData);52 } else {53 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] );54 }55 return;56}57js3_1_0.do_setup = function(subscriberName) {58 js3_1_0.subscribe[subscriberName] = true;59 if (js3_1_0.subscribe["_trigger"] === true) {60 this.hubClient.publish("pub.same", { step: "setup" }); 61 }62}63js3_1_0.do_fire = function(data) {64 js3_1_0.setup[data] = true;65 if (js3_1_0.setup["_trigger"] === true) {66 this.hubClient.publish("pub.same", { step: "fire" });67 }68}69js3_1_0.do_check = function(data) {70 js3_1_0.fire[data] = true;71 if (js3_1_0.fire["_trigger"] === true) {72 this.hubClient.publish("pub.same", { step: "check" });73 }74}75js3_1_0.do_finish = function(data) {76 js3_1_0.check[data] = true;77 if (js3_1_0.check["_trigger"] === true) {78 if (js3_1_0.setup["_trigger"] === true && 79 js3_1_0.fire["_trigger"] === true && 80 js3_1_0.check["_trigger"] === true) {81 this.sendMsg( ["done"] );82 } else {83 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.0"] );84 }85 }86}87//////////////////////////////////////////////////////88js3_1_1.run = function(scriptnum) {89 js3_1_1.scriptnum = scriptnum;90 js3_1_1.subscribe = {};91 js3_1_1.setup = {};92 js3_1_1.fire = {};93 js3_1_1.check = {};94 // In callback for topic X, subscribe to topic X 95 this.hubClient.subscribe("pub.other.trigger", js3_1.cbPubOther, this, function( subscriptionID, success, errCode ) {96 js3_1_1.do_setup.call(this, "_trigger");97 }, "_trigger");98 this.hubClient.subscribe("pub.other.target", js3_1.cbPubOther, this, function( subscriptionID, success, errCode ) {99 js3_1_1.do_setup.call(this, "_target");100 }, "_target");101}102js3_1.cbPubOther = function(subject, message, subscriberData) {103 if(message.step == "setup") {104 js3_1_1.do_fire.call(this, subscriberData);105 } else if(message.step == "fire") {106 js3_1_1.do_check.call(this, subscriberData);107 } else if(message.step == "check") {108 js3_1_1.do_finish.call(this, subscriberData);109 } else {110 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] );111 }112 return;113}114js3_1_1.do_setup = function(subscriberName) {115 js3_1_1.subscribe[subscriberName] = true;116 if (js3_1_1.subscribe["_trigger"] === true && js3_1_1.subscribe["_target"] === true) {117 this.hubClient.publish("pub.other.trigger", { step: "setup" }); 118 this.hubClient.publish("pub.other.target", { step: "setup" }); 119 }120}121js3_1_1.do_fire = function(data) {122 js3_1_1.setup[data] = true;123 if (js3_1_1.setup["_trigger"] === true && js3_1_1.setup["_target"] === true) {124 this.hubClient.publish("pub.other.trigger", { step: "fire" });125 }126}127js3_1_1.do_check = function(data) {128 js3_1_1.fire[data] = true;129 if (js3_1_1.fire["_trigger"] === true) {130 this.hubClient.publish("pub.other.target", { step: "check" });131 }132}133js3_1_1.do_finish = function(data) {134 js3_1_1.check[data] = true;135 if (js3_1_1.check["_target"] === true) {136 if (js3_1_1.setup["_trigger"] === true && js3_1_1.setup["_target"] === true &&137 js3_1_1.fire["_trigger"] === true && typeof js3_1_1.fire["_target"] === "undefined" &&138 typeof js3_1_1.check["_trigger"] === "undefined" && js3_1_1.check["_target"] === true) {139 this.sendMsg( ["done"] );140 } else {141 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.1"] );142 }143 }144}145//////////////////////////////////////////////////////146js3_1_2.run = function(scriptnum) {147 js3_1_2.scriptnum = scriptnum;148 js3_1_2.subscribe = {};149 js3_1_2.setup = {};150 js3_1_2.fire = {};151 js3_1_2.check = {};152 // In callback for topic X, subscribe to topic X 153 this.hubClient.subscribe("sub.same", js3_1.cbSubSame, this, function( subscriptionID, success, errCode ) {154 js3_1_2.do_setup.call(this, "_trigger");155 }, "_trigger");156}157js3_1.cbSubSame = function(subject, message, subscriberData) {158 if(message.step == "setup") {159 js3_1_2.do_fire.call(this, subscriberData);160 } else if(message.step == "fire") {161 this.hubClient.subscribe(subject, js3_1.cbSubSame, this, function( subscriptionID, success, errCode ) {162 js3_1_2.do_check.call(this, subscriberData);163 }, "_target");164 } else if(message.step == "check") {165 js3_1_2.do_finish.call(this, subscriberData);166 } else {167 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 168 }169 return;170}171js3_1_2.do_setup = function(subscriberName) {172 js3_1_2.subscribe[subscriberName] = true;173 if (js3_1_2.subscribe["_trigger"] === true) {174 this.hubClient.publish("sub.same", { step: "setup" }); 175 }176}177js3_1_2.do_fire = function(data) {178 js3_1_2.setup[data] = true;179 if (js3_1_2.setup["_trigger"] === true) {180 this.hubClient.publish("sub.same", { step: "fire" });181 }182}183js3_1_2.do_check = function(data) {184 js3_1_2.fire[data] = true;185 if (js3_1_2.fire["_trigger"] === true) {186 this.hubClient.publish("sub.same", { step: "check" });187 }188}189js3_1_2.do_finish = function(data) {190 js3_1_2.check[data] = true;191 if (js3_1_2.check["_trigger"] === true && js3_1_2.check["_target"] === true) {192 if (js3_1_2.setup["_trigger"] === true && typeof js3_1_2.setup["_target"] === "undefined" &&193 js3_1_2.fire["_trigger"] === true && typeof js3_1_2.fire["_target"] === "undefined" &&194 js3_1_2.check["_trigger"] === true && js3_1_2.check["_target"] === true) {195 this.sendMsg( ["done"] );196 } else {197 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.2"] );198 }199 }200}201//////////////////////////////////////////////////////202js3_1_3.run = function(scriptnum) {203 js3_1_3.scriptnum = scriptnum;204 js3_1_3.subscribe = {};205 js3_1_3.setup = {};206 js3_1_3.fire = {};207 js3_1_3.check = {};208 // In callback for topic X, subscribe to topic Y 209 this.hubClient.subscribe("sub.other.trigger", js3_1.cbSubOther, this, function( subscriptionID, success, errCode ) {210 js3_1_3.do_setup.call(this, "_trigger");211 }, "_trigger");212}213js3_1.cbSubOther = function(subject, message, subscriberData) {214 if(message.step == "setup") { 215 js3_1_3.do_fire.call(this, subscriberData);216 } else if(message.step == "fire") {217 this.hubClient.subscribe("sub.other.target", js3_1.cbSubOther, this, function( subscriptionID, success, errCode ) {218 js3_1_3.do_check.call(this, subscriberData);219 }, "_target");220 } else if(message.step == "check") {221 js3_1_3.do_finish.call(this, subscriberData);222 } else {223 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 224 }225 return;226}227js3_1_3.do_setup = function(subscriberName) {228 js3_1_3.subscribe[subscriberName] = true;229 if (js3_1_3.subscribe["_trigger"] === true) {230 this.hubClient.publish("sub.other.trigger", { step: "setup" }); 231 this.hubClient.publish("sub.other.target", { step: "setup" }); 232 }233}234js3_1_3.do_fire = function(data) {235 js3_1_3.setup[data] = true;236 if (js3_1_3.setup["_trigger"] === true) {237 this.hubClient.publish("sub.other.trigger", { step: "fire" });238 }239}240js3_1_3.do_check = function(data) {241 js3_1_3.fire[data] = true;242 if (js3_1_3.fire["_trigger"] === true) {243 this.hubClient.publish("sub.other.trigger", { step: "check" });244 this.hubClient.publish("sub.other.target", { step: "check" });245 }246}247js3_1_3.do_finish = function(data) {248 js3_1_3.check[data] = true;249 if (js3_1_3.check["_trigger"] === true && js3_1_3.check["_target"] === true) {250 if (js3_1_3.setup["_trigger"] === true && typeof js3_1_3.setup["_target"] === "undefined" &&251 js3_1_3.fire["_trigger"] === true && typeof js3_1_3.fire["_target"] === "undefined" &&252 js3_1_3.check["_trigger"] === true && js3_1_3.check["_target"] === true) {253 this.sendMsg( ["done"] );254 } else {255 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.3"] );256 }257 }258}259//////////////////////////////////////////////////////260js3_1_4.run = function(scriptnum) {261 js3_1_4.scriptnum = scriptnum;262 js3_1_4.subscribe = {};263 js3_1_4.setup = {};264 js3_1_4.fire = {};265 js3_1_4.check = {};266 // In callback for topic X, cancel another subscription to the same topic X267 this.hubClient.subscribe("unsub.same", js3_1.cbUnsubSame, this, function( subscriptionID, success, errCode ) {268 js3_1_4.do_setup.call(this, "_trigger");269 }, "_trigger");270 this.hubClient.subscribe("unsub.same", js3_1.cbUnsubSame, this, function( subscriptionID, success, errCode ) {271 this.subUnsubSameSubjectTarget = subscriptionID;272 js3_1_4.do_setup.call(this, "_target");273 }, "_target");274}275js3_1.cbUnsubSame = function(subject, message, subscriberData) {276 if(message.step == "setup") { 277 js3_1_4.do_fire.call(this, subscriberData);278 } else if(message.step == "fire") {279 if(subscriberData == "_trigger") {280 this.hubClient.unsubscribe(this.subUnsubSameSubjectTarget, function( subscriptionID, success, errCode ) {281 js3_1_4.do_check.call(this, subscriberData); 282 }, this);283 }284 } else if(message.step == "check") { 285 js3_1_4.do_finish.call(this, subscriberData);286 } else {287 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 288 }289 return;290}291js3_1_4.do_setup = function(subscriberName) {292 js3_1_4.subscribe[subscriberName] = true;293 if (js3_1_4.subscribe["_trigger"] === true && js3_1_4.subscribe["_target"] === true) {294 this.hubClient.publish("unsub.same", { step: "setup" }); 295 }296}297js3_1_4.do_fire = function(data) {298 js3_1_4.setup[data] = true;299 if (js3_1_4.setup["_trigger"] === true && js3_1_4.setup["_target"] === true) {300 this.hubClient.publish("unsub.same", { step: "fire" });301 }302}303js3_1_4.do_check = function(data) {304 js3_1_4.fire[data] = true;305 if (js3_1_4.fire["_trigger"] === true) {306 this.hubClient.publish("unsub.same", { step: "check" });307 }308}309js3_1_4.do_finish = function(data) {310 js3_1_4.check[data] = true;311 if (js3_1_4.check["_trigger"] === true) {312 if (js3_1_4.setup["_trigger"] === true && js3_1_4.setup["_target"] === true &&313 js3_1_4.fire["_trigger"] === true && typeof js3_1_4.fire["_target"] === "undefined" &&314 js3_1_4.check["_trigger"] === true && typeof js3_1_4.check["_target"] === "undefined") {315 this.sendMsg( ["done"] );316 } else {317 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.4"] );318 }319 }320}321//////////////////////////////////////////////////////322js3_1_5.run = function(scriptnum) {323 js3_1_5.scriptnum = scriptnum;324 js3_1_5.subscribe = {};325 js3_1_5.setup = {};326 js3_1_5.fire = {};327 js3_1_5.check = {};328 // In callback for topic X, cancel a subscription to a different topic Y329 this.hubClient.subscribe("unsub.other.trigger", js3_1.cbUnsubOther, this, function( subscriptionID, success, errCode ) {330 js3_1_5.do_setup.call(this, "unsub.other.trigger");331 }, "_trigger");332 this.hubClient.subscribe("unsub.other.target", js3_1.cbUnsubOther, this, function( subscriptionID, success, errCode ) {333 this.subUnsubOtherTarget = subscriptionID;334 js3_1_5.do_setup.call(this, "unsub.other.target");335 }, "_target");336}337js3_1.cbUnsubOther = function(subject, message, subscriberData) {338 if(message.step == "setup") {339 js3_1_5.do_fire.call(this, subject);340 } else if(message.step == "fire") {341 this.hubClient.unsubscribe(this.subUnsubOtherTarget, function( subscriptionID, success, errCode ) {342 js3_1_5.do_check.call(this, subject); 343 }, this);344 } else if(message.step == "check") {345 js3_1_5.do_finish.call(this, subject);346 } else {347 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 348 }349 return;350}351js3_1_5.do_setup = function(subscriberName) {352 js3_1_5.subscribe[subscriberName] = true;353 if (js3_1_5.subscribe["unsub.other.trigger"] === true && js3_1_5.subscribe["unsub.other.target"] === true) {354 this.hubClient.publish("unsub.other.trigger", { step: "setup" }); 355 this.hubClient.publish("unsub.other.target", { step: "setup" });356 }357}358js3_1_5.do_fire = function(data) {359 js3_1_5.setup[data] = true;360 if (js3_1_5.setup["unsub.other.trigger"] === true && js3_1_5.setup["unsub.other.target"] === true) {361 this.hubClient.publish("unsub.other.trigger", { step: "fire" });362 }363}364js3_1_5.do_check = function(data) {365 js3_1_5.fire[data] = true;366 if (js3_1_5.fire["unsub.other.trigger"] === true) {367 this.hubClient.publish("unsub.other.trigger", { step: "check" });368 this.hubClient.publish("unsub.other.target", { step: "check" });369 }370}371js3_1_5.do_finish = function(data) {372 js3_1_5.check[data] = true;373 if (js3_1_5.check["unsub.other.trigger"] === true) {374 if (js3_1_5.setup["unsub.other.trigger"] === true && js3_1_5.setup["unsub.other.target"] === true &&375 js3_1_5.fire["unsub.other.trigger"] === true && typeof js3_1_5.fire["unsub.other.target"] === "undefined" &&376 js3_1_5.check["unsub.other.trigger"] === true && typeof js3_1_5.check["unsub.other.target"] === "undefined") {377 this.sendMsg( ["done"] );378 } else {379 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.5"] );380 }381 }382}383//////////////////////////////////////////////////////384js3_1_6.run = function(scriptnum) {385 this.scriptnum = scriptnum;386 js3_1_6.subscribe = {};387 js3_1_6.setup = {};388 js3_1_6.fire = {};389 js3_1_6.check = {};390 // In callback for topic X, cancel this same subscription 391 this.hubClient.subscribe("unsub.this", js3_1.cbUnsubThis, this, function( subscriptionID, success, errCode ) {392 this.subUnsubThis = subscriptionID;393 js3_1_6.do_setup.call(this, "unsub.this");394 }, "");395}396js3_1.cbUnsubThis = function(subject, message, subscriberData) {397 if(message.step == "setup") {398 js3_1_6.do_fire.call(this, subject);399 } else if(message.step == "fire") {400 this.hubClient.unsubscribe(this.subUnsubThis, function( subscriptionID, success, errCode ) {401 js3_1_6.do_check.call(this, subject); 402 }, this);403 } else if(message.step == "check") {404 this.sendMsg( ["error", "ERROR " + message.step + " should not happen, " ] ); 405 } else {406 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 407 }408 return;409}410js3_1_6.do_setup = function(subscriberName) {411 js3_1_6.subscribe[subscriberName] = true;412 if (js3_1_6.subscribe["unsub.this"] === true) {413 this.hubClient.publish("unsub.this", { step: "setup" }); 414 }415}416js3_1_6.do_fire = function(data) {417 js3_1_6.setup[data] = true;418 if (js3_1_6.setup["unsub.this"] === true) {419 this.hubClient.publish("unsub.this", { step: "fire" });420 }421}422js3_1_6.do_check = function(data) {423 js3_1_6.fire[data] = true;424 if (js3_1_6.fire["unsub.this"] === true) {425 this.hubClient.publish("unsub.this", { step: "check" });426 js3_1_6.do_finish.call(this, null);427 }428}429js3_1_6.do_finish = function(data) {430 if (js3_1_6.setup["unsub.this"] === true && 431 js3_1_6.fire["unsub.this"] === true && 432 typeof js3_1_6.check["unsub.this"] === "undefined") {433 this.sendMsg( ["done"] );434 } else {435 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.6"] );436 }437}438//////////////////////////////////////////////////////439js3_1_7.run = function(scriptnum) {440 this.scriptnum = scriptnum;441 js3_1_7.subscribe = {};442 js3_1_7.setup = {};443 js3_1_7.fire = {};444 js3_1_7.check = {};445 // In callback for topic X, subscribe to X and publish to X446 this.hubClient.subscribe("sub.pub.same", js3_1.cbSubPubSame, this, function( subscriptionID, success, errCode ) {447 js3_1_7.do_setup.call(this, "_trigger");448 }, "_trigger");449}450js3_1.cbSubPubSame = function(subject, message, subscriberData) {451 if(message.step == "setup") 452 js3_1_7.do_fire.call(this, subscriberData);453 else if(message.step == "fire") {454 this.hubClient.subscribe(subject, js3_1.cbSubPubSame, this, function( subscriptionID, success, errCode ) {455 js3_1_7.do_check.call(this, subscriberData); 456 }, "_target");457 } else if(message.step == "check1") {458 /* message received. should be received ONCE FOR _trigger & ONCE FOR _target. */ 459 js3_1_7.do_finish.call(this, message.step+subscriberData); 460 } else if(message.step == "check2") {461 /* message received. should be received ONCE FOR _trigger & ONCE FOR _target. */462 js3_1_7.do_finish.call(this, message.step+subscriberData); 463 } else464 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 465 return;466}467js3_1_7.do_setup = function(subscriberData) {468 js3_1_7.subscribe[subscriberData] = true;469 if (js3_1_7.subscribe["_trigger"] === true) {470 this.hubClient.publish("sub.pub.same", { step: "setup" }); 471 }472}473js3_1_7.do_fire = function(data) {474 js3_1_7.setup[data] = true;475 if (js3_1_7.setup["_trigger"] === true) {476 this.hubClient.publish("sub.pub.same", { step: "fire" });477 }478}479js3_1_7.do_check = function(data) {480 js3_1_7.fire[data] = true;481 if (js3_1_7.fire["_trigger"] === true) {482 this.hubClient.publish("sub.pub.same", { step: "check1" });483 this.hubClient.publish("sub.pub.same", { step: "check2" });484 }485}486js3_1_7.do_finish = function(data) {487 js3_1_7.check[data] = true;488 if (js3_1_7.check["check1_trigger"] === true && js3_1_7.check["check1_target"] === true && 489 js3_1_7.check["check2_trigger"] === true && js3_1_7.check["check2_target"] === true) {490 if (js3_1_7.setup["_trigger"] === true && typeof js3_1_7.setup["_target"] === "undefined" &&491 js3_1_7.fire["_trigger"] === true && typeof js3_1_7.fire["_target"] === "undefined" &&492 js3_1_7.check["check1_trigger"] === true && js3_1_7.check["check1_target"] === true && 493 js3_1_7.check["check2_trigger"] === true && js3_1_7.check["check2_target"] === true) {494 this.sendMsg( ["done"] );495 } else {496 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.7"] );497 }498 }499}500//////////////////////////////////////////////////////501js3_1_8.run = function(scriptnum) {502 js3_1_8.scriptnum = scriptnum;503 js3_1_8.subscribe = {};504 js3_1_8.setup = {};505 js3_1_8.fire = {};506 js3_1_8.check = {};507 this.hubClient.subscribe("sub.pub.other.trigger", js3_1.cbSubPubOther, this, function( subscriptionID, success, errCode ) {508 js3_1_8.do_setup.call(this, "sub.pub.other.trigger");509 }, "_trigger");510}511js3_1.cbSubPubOther = function(subject, message, subscriberData) {512 var pubSubject = "sub.pub.other.target";513 if(message.step == "setup") 514 js3_1_8.do_fire.call(this, subject);515 else if(message.step == "fire") {516 this.hubClient.subscribe(pubSubject, js3_1.cbSubPubOther, this, function( subscriptionID, success, errCode ) {517 js3_1_8.do_check.call(this, subject);518 }, "_target");519 } else if(message.step == "check1") {520 /* message received. should be received ONCE FOR _target ONLY. */ 521 js3_1_8.do_finish.call(this, message.step+subscriberData); 522 } else if(message.step == "check2") {523 /* message received. should be received ONCE FOR _target ONLY. */524 js3_1_8.do_finish.call(this, message.step+subscriberData); 525 } else526 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 527 return;528}529js3_1_8.do_setup = function(subscriberName) {530 js3_1_8.subscribe[subscriberName] = true;531 if (js3_1_8.subscribe["sub.pub.other.trigger"] === true) {532 this.hubClient.publish("sub.pub.other.trigger", { step: "setup" }); 533 this.hubClient.publish("sub.pub.other.target", { step: "setup" }); 534 }535}536js3_1_8.do_fire = function(data) {537 js3_1_8.setup[data] = true;538 if (js3_1_8.setup["sub.pub.other.trigger"] === true) {539 this.hubClient.publish("sub.pub.other.trigger", { step: "fire" });540 }541}542js3_1_8.do_check = function(subject) {543 js3_1_8.fire[subject] = true;544 if (js3_1_8.fire["sub.pub.other.trigger"] === true) {545 this.hubClient.publish("sub.pub.other.target", { step: "check1" });546 this.hubClient.publish("sub.pub.other.trigger", { step: "check2" });547 this.hubClient.publish("sub.pub.other.target", { step: "check2" });548 }549}550js3_1_8.do_finish = function(data) {551 js3_1_8.check[data] = true;552 if (js3_1_8.check["check1_target"] === true && 553 js3_1_8.check["check2_trigger"] === true && js3_1_8.check["check2_target"] === true) {554 if (js3_1_8.setup["sub.pub.other.trigger"] === true && typeof js3_1_8.setup["sub.pub.other.target"] === "undefined" &&555 js3_1_8.fire["sub.pub.other.trigger"] === true && typeof js3_1_8.fire["sub.pub.other.target"] === "undefined" &&556 typeof js3_1_8.check["check1_trigger"] === "undefined" && js3_1_8.check["check1_target"] === true && 557 js3_1_8.check["check2_trigger"] === true && js3_1_8.check["check2_target"] === true) {558 this.sendMsg( ["done"] );559 } else {560 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.8"] );561 }562 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...109const benchmarkRunner = new Runner()110 .suite('bsonBench', suite =>111 suite112 .benchmark('flatBsonEncoding', benchmark =>113 benchmark.taskSize(75.31).setup(makeBSONLoader('flat_bson')).task(encodeBSON)114 )115 .benchmark('flatBsonDecoding', benchmark =>116 benchmark.taskSize(75.31).setup(makeBSONLoader('flat_bson')).task(decodeBSON)117 )118 .benchmark('deepBsonEncoding', benchmark =>119 benchmark.taskSize(19.64).setup(makeBSONLoader('deep_bson')).task(encodeBSON)120 )121 .benchmark('deepBsonDecoding', benchmark =>122 benchmark.taskSize(19.64).setup(makeBSONLoader('deep_bson')).task(decodeBSON)123 )124 .benchmark('fullBsonEncoding', benchmark =>125 benchmark.taskSize(57.34).setup(makeBSONLoader('full_bson')).task(encodeBSON)126 )127 .benchmark('fullBsonDecoding', benchmark =>128 benchmark.taskSize(57.34).setup(makeBSONLoader('full_bson')).task(decodeBSON)129 )130 )131 .suite('singleBench', suite =>132 suite133 .benchmark('runCommand', benchmark =>134 benchmark135 .taskSize(0.16)136 .setup(makeClient)137 .setup(connectClient)138 .setup(initDb)139 .task(runCommand)140 .teardown(disconnectClient)141 )142 .benchmark('findOne', benchmark =>143 benchmark144 .taskSize(16.22)145 .setup(makeLoadJSON('tweet.json'))146 .setup(makeClient)147 .setup(connectClient)148 .setup(initDb)149 .setup(dropDb)150 .setup(initCollection)151 .setup(makeLoadTweets(true))152 .task(findOneById)153 .teardown(dropDb)154 .teardown(disconnectClient)155 )156 .benchmark('smallDocInsertOne', benchmark =>157 benchmark158 .taskSize(2.75)159 .setup(makeLoadJSON('small_doc.json'))160 .setup(makeClient)161 .setup(connectClient)162 .setup(initDb)163 .setup(dropDb)164 .setup(initDb)165 .setup(initCollection)166 .setup(createCollection)167 .beforeTask(dropCollection)168 .beforeTask(createCollection)169 .beforeTask(initCollection)170 .task(makeTestInsertOne(10000))171 .teardown(dropDb)172 .teardown(disconnectClient)173 )174 .benchmark('largeDocInsertOne', benchmark =>175 benchmark176 .taskSize(27.31)177 .setup(makeLoadJSON('large_doc.json'))178 .setup(makeClient)179 .setup(connectClient)180 .setup(initDb)181 .setup(dropDb)182 .setup(initDb)183 .setup(initCollection)184 .setup(createCollection)185 .beforeTask(dropCollection)186 .beforeTask(createCollection)187 .beforeTask(initCollection)188 .task(makeTestInsertOne(10))189 .teardown(dropDb)190 .teardown(disconnectClient)191 )192 )193 .suite('multiBench', suite =>194 suite195 .benchmark('findManyAndEmptyCursor', benchmark =>196 benchmark197 .taskSize(16.22)198 .setup(makeLoadJSON('tweet.json'))199 .setup(makeClient)200 .setup(connectClient)201 .setup(initDb)202 .setup(dropDb)203 .setup(initCollection)204 .setup(makeLoadTweets(false))205 .task(findManyAndEmptyCursor)206 .teardown(dropDb)207 .teardown(disconnectClient)208 )209 .benchmark('smallDocBulkInsert', benchmark =>210 benchmark211 .taskSize(2.75)212 .setup(makeLoadJSON('small_doc.json'))213 .setup(makeLoadInsertDocs(10000))214 .setup(makeClient)215 .setup(connectClient)216 .setup(initDb)217 .setup(dropDb)218 .setup(initDb)219 .setup(initCollection)220 .setup(createCollection)221 .beforeTask(dropCollection)222 .beforeTask(createCollection)223 .beforeTask(initCollection)224 .task(docBulkInsert)225 .teardown(dropDb)226 .teardown(disconnectClient)227 )228 .benchmark('largeDocBulkInsert', benchmark =>229 benchmark230 .taskSize(27.31)231 .setup(makeLoadJSON('large_doc.json'))232 .setup(makeLoadInsertDocs(10))233 .setup(makeClient)234 .setup(connectClient)235 .setup(initDb)236 .setup(dropDb)237 .setup(initDb)238 .setup(initCollection)239 .setup(createCollection)240 .beforeTask(dropCollection)241 .beforeTask(createCollection)242 .beforeTask(initCollection)243 .task(docBulkInsert)244 .teardown(dropDb)245 .teardown(disconnectClient)246 )247 .benchmark('gridFsUpload', benchmark =>248 benchmark249 .taskSize(52.43)250 .setup(loadGridFs)251 .setup(makeClient)252 .setup(connectClient)253 .setup(initDb)254 .setup(dropDb)255 .setup(initDb)256 .setup(initCollection)257 .beforeTask(dropBucket)258 .beforeTask(initBucket)259 .beforeTask(gridFsInitUploadStream)260 .beforeTask(writeSingleByteToUploadStream)261 .task(function (done) {262 this.stream.on('error', done).end(this.bin, null, () => done());263 })264 .teardown(dropDb)265 .teardown(disconnectClient)266 )267 .benchmark('gridFsDownload', benchmark =>268 benchmark269 .taskSize(52.43)270 .setup(loadGridFs)271 .setup(makeClient)272 .setup(connectClient)273 .setup(initDb)274 .setup(dropDb)275 .setup(initDb)276 .setup(initCollection)277 .setup(dropBucket)278 .setup(initBucket)279 .setup(gridFsInitUploadStream)280 .setup(function () {281 return new Promise((resolve, reject) => {282 this.stream.end(this.bin, null, err => {283 if (err) {284 return reject(err);285 }286 this.id = this.stream.id;287 this.stream = undefined;288 resolve();289 });290 });291 })292 .task(function (done) {293 this.bucket.openDownloadStream(this.id).resume().on('end', done);294 })...

Full Screen

Full Screen

testFloat32-correctness.js

Source:testFloat32-correctness.js Github

copy

Full Screen

...4 if (f === undefined) {5 f = setup;6 setup = function(){};7 }8 setup();9 for(var n = 200; n; --n) {10 f();11 }12}13// Basic arithmetic14function setupBasicArith() {15 f32[0] = -Infinity;16 f32[1] = -1;17 f32[2] = -0;18 f32[3] = 0;19 f32[4] = 1.337;20 f32[5] = 42;21 f32[6] = Infinity;22 f32[7] = NaN;...

Full Screen

Full Screen

PairDevice.js

Source:PairDevice.js Github

copy

Full Screen

1/**2 * comma SetupEonPairing Screen3 */4import React, {useState, useEffect} from 'react';5import {View, Linking, StyleSheet, Text, Button} from 'react-native';6import {useNavigation} from '@react-navigation/native';7import Permissions from 'react-native-permissions';8import QRCodeScanner from 'react-native-qrcode-scanner';9import X from '../../theme';10import BasePage from '../Util/BasePage';11// import WideButton from '../../components/Util/WideButton';12// import {Alert, Spinner} from '../../components';13import {14 pilotPair,15 fetchDevices,16 fetchDevice,17 fetchDeviceSubscription,18} from '../../actions/Devices';19import gStyles from '../../constants/styles';20export default SetupEonPairing = () => {21 const [wantsCameraPermissions, setWantsCameraPermissions] = useState(false);22 const [hasCameraPermissions, setHasCameraPermissions] = useState(false);23 const [attemptingPair, setAttemptingPair] = useState(false);24 const navigation = useNavigation();25 useEffect(() => {26 Permissions.check('camera').then((response) => {27 if (response == 'authorized') {28 setHasCameraPermissions(true);29 }30 });31 }, []);32 const pairDevice = (imei, serial, pairToken) => {33 return pilotPair(imei, serial, pairToken)34 .then((dongleId) => {35 // dispatch(fetchDevices());36 return Promise.all([37 fetchDevice(dongleId),38 fetchDeviceSubscription(dongleId),39 ]);40 })41 .then(([device, deviceSubscription]) => {42 if (deviceSubscription && deviceSubscription.trial_claimable) {43 navigation.navigate('PrimeSignup', {dongleId: device.dongle_id});44 } else {45 navigation.navigate('AppDrawer');46 }47 });48 };49 const handleConfirmPressed = () => {50 setWantsCameraPermissions(true);51 };52 const handleDismissPressed = () => {53 navigation.navigate('Home');54 };55 const handleViewSetupGuidePressed = () => {56 Linking.openURL('https://comma.ai/setup');57 };58 const handleScannedQRCode = (e) => {59 setAttemptingPair(true);60 let imei, serial, pairToken;61 let qrDataSplit = e.data.split('--');62 if (qrDataSplit.length === 2) {63 imei = qrDataSplit[0];64 serial = qrDataSplit[1];65 } else if (qrDataSplit.length >= 3) {66 imei = qrDataSplit[0];67 serial = qrDataSplit[1];68 pairToken = qrDataSplit.slice(2).join('--');69 }70 if (imei === undefined || serial === undefined) {71 setAttemptingPair(false);72 }73 pairDevice(imei, serial, pairToken).catch((err) => {74 setAttemptingPair(false);75 console.log(err);76 });77 };78 if (attemptingPair) {79 return (80 <View style={styles.setupEonPairingContainer}>81 <Text style={{color: '#fff', fontSize: 20}}>Spinner</Text>82 {/* <Spinner spinnerMessage="Pairing Device..." /> */}83 </View>84 );85 // } else if (wantsCameraPermissions || hasCameraPermissions) {86 } else {87 return (88 <BasePage title="Pair Your Device">89 <View style={styles.setupEonPairingContainer}>90 <X.Entrance style={styles.setupEonPairingCamera}>91 <QRCodeScanner92 onRead={handleScannedQRCode}93 topContent={null}94 bottomContent={null}95 cameraProps={{captureAudio: false}}96 />97 </X.Entrance>98 <View style={styles.setupEonPairingInstruction}>99 <X.Text style={styles.setupEonPairingInstructionText}>100 Place the QR code from your device during setup within the frame.101 </X.Text>102 <Button103 onPress={handleViewSetupGuidePressed}104 title="View Setup Guide"105 color="#fff"></Button>106 </View>107 </View>108 </BasePage>109 );110 // } else {111 // return (112 // <BasePage>113 // <View style={styles.setupEonPairingContainer}>114 // <X.Entrance style={{height: '100%'}}>115 // <Text style={{color:'#fff', fontSize: 20}}>Alert</Text>116 {117 /* <Alert118 title="Camera Access"119 message="We need camera access so you can finish setting up your device"120 dismissButtonAction={handleDismissPressed}121 confirmButtonAction={handleConfirmPressed}122 dismissButtonTitle="Not now"123 confirmButtonTitle="Yes!"124 /> */125 }126 // </X.Entrance>127 // </View>128 // </BasePage>129 // );130 }131};132const styles = StyleSheet.create({133 setupDevicesContainer: {134 backgroundColor: '#080808',135 height: '100%',136 width: '100%',137 },138 setupDevicesHeader: {139 alignItems: 'center',140 paddingLeft: 30,141 paddingRight: 30,142 },143 setupDevicesOptions: {144 marginTop: '10%',145 },146 setupDeviceOptionEON: {147 backgroundColor: 'rgba(255,255,255,.1)',148 borderRadius: 8,149 height: 240,150 marginBottom: '10%',151 alignItems: 'center',152 justifyContent: 'center',153 width: '100%',154 },155 setupDeviceOptionEONImage: {156 maxHeight: 120,157 marginBottom: 20,158 width: '80%',159 },160 setupDeviceOptionPanda: {161 justifyContent: 'center',162 backgroundColor: 'rgba(255,255,255,.1)',163 borderRadius: 8,164 flexDirection: 'row',165 height: 160,166 width: '100%',167 },168 setupDeviceOptionPandaImage: {169 maxWidth: 100,170 },171 setupDeviceOptionPandaText: {172 alignSelf: 'center',173 paddingLeft: '8%',174 },175 setupDeviceOptionShopText: {176 textAlign: 'center',177 },178 setupDeviceContainer: {179 width: '100%',180 },181 setupDeviceHeader: {182 alignItems: 'center',183 height: 50,184 },185 setupDeviceBody: {186 paddingLeft: '3%',187 paddingRight: '3%',188 },189 setupDeviceBodyCentered: {190 height: '90%',191 alignItems: 'center',192 justifyContent: 'center',193 paddingBottom: '20%',194 },195 setupDeviceIntroBodyItem: {196 marginTop: '10%',197 },198 setupDeviceIntroBodyItemHeader: {199 marginBottom: '3.5%',200 },201 setupEonPairingContainer: {202 height: '100%',203 width: '100%',204 },205 setupEonPairingCamera: {206 backgroundColor: 'rgba(255,255,255,.02)',207 height: '50%',208 },209 setupEonPairingInstruction: {210 alignItems: 'center',211 height: '30%',212 justifyContent: 'center',213 padding: '15%',214 paddingBottom: '5%',215 paddingTop: 0,216 fontSize: 30,217 },218 setupEonPairingInstructionHdr: {219 textAlign: 'center',220 color: '#fff',221 fontSize: 30,222 fontWeight: '700',223 },224 setupEonPairingInstructionText: {225 marginTop: '6%',226 marginBottom: '12%',227 textAlign: 'center',228 color: '#aaa',229 fontSize: gStyles.text.small,230 },231 setupEonPairingInstructionButton: {232 backgroundColor: '#fff',233 borderRadius: 30,234 height: 60,235 width: 60,236 },237 setupDeviceInstallPrepContainer: {238 height: '100%',239 width: '100%',240 },241 setupDeviceInstallPrepHeader: {},242 setupDeviceInstallPrepBody: {243 justifyContent: 'center',244 flex: 1,245 },246 setupDeviceInstallSteps: {247 borderTopColor: 'rgba(255,255,255,.2)',248 borderTopWidth: 1,249 paddingTop: 20,250 },251 setupDeviceInstallStep: {252 flexDirection: 'row',253 paddingTop: 20,254 paddingBottom: 20,255 },256 setupDeviceInstallStepNumber: {257 alignItems: 'center',258 backgroundColor: '#fff',259 borderRadius: 15,260 height: 26,261 justifyContent: 'center',262 width: 26,263 },264 setupDeviceInstallStepCopy: {265 paddingLeft: 15,266 paddingRight: 20,267 },268 setupDeviceInstallVideo: {269 backgroundColor: '#fff',270 borderColor: '#fff',271 borderRadius: 8,272 borderWidth: 10,273 marginTop: 10,274 marginBottom: 30,275 height: 200,276 width: '100%',277 alignSelf: 'center',278 },279 setupDeviceInstallVideoCover: {280 borderRadius: 8,281 height: 148,282 },283 setupDeviceInstallVideoButton: {284 alignItems: 'center',285 backgroundColor: '#fff',286 justifyContent: 'center',287 height: 40,288 paddingTop: 10,289 },...

Full Screen

Full Screen

authentication.js

Source:authentication.js Github

copy

Full Screen

1const api = require('./index');2const config = require('../../../shared/config');3const {i18n} = require('../../lib/common');4const errors = require('@tryghost/errors');5const web = require('../../web');6const models = require('../../models');7const auth = require('../../services/auth');8const invitations = require('../../services/invitations');9module.exports = {10 docName: 'authentication',11 setup: {12 statusCode: 201,13 permissions: false,14 validation: {15 docName: 'setup'16 },17 query(frame) {18 return Promise.resolve()19 .then(() => {20 return auth.setup.assertSetupCompleted(false)();21 })22 .then(() => {23 const setupDetails = {24 name: frame.data.setup[0].name,25 email: frame.data.setup[0].email,26 password: frame.data.setup[0].password,27 blogTitle: frame.data.setup[0].blogTitle,28 status: 'active'29 };30 return auth.setup.setupUser(setupDetails);31 })32 .then((data) => {33 return auth.setup.doSettings(data, api.settings);34 })35 .then((user) => {36 return auth.setup.sendWelcomeEmail(user.get('email'), api.mail)37 .then(() => user);38 });39 }40 },41 updateSetup: {42 permissions: (frame) => {43 return models.User.findOne({role: 'Owner', status: 'all'})44 .then((owner) => {45 if (owner.id !== frame.options.context.user) {46 throw new errors.NoPermissionError({message: i18n.t('errors.api.authentication.notTheBlogOwner')});47 }48 });49 },50 validation: {51 docName: 'setup'52 },53 query(frame) {54 return Promise.resolve()55 .then(() => {56 return auth.setup.assertSetupCompleted(true)();57 })58 .then(() => {59 const setupDetails = {60 name: frame.data.setup[0].name,61 email: frame.data.setup[0].email,62 password: frame.data.setup[0].password,63 blogTitle: frame.data.setup[0].blogTitle,64 status: 'active'65 };66 return auth.setup.setupUser(setupDetails);67 })68 .then((data) => {69 return auth.setup.doSettings(data, api.settings);70 });71 }72 },73 isSetup: {74 permissions: false,75 query() {76 return auth.setup.checkIsSetup()77 .then((isSetup) => {78 return {79 status: isSetup,80 // Pre-populate from config if, and only if the values exist in config.81 title: config.title || undefined,82 name: config.user_name || undefined,83 email: config.user_email || undefined84 };85 });86 }87 },88 generateResetToken: {89 validation: {90 docName: 'passwordreset'91 },92 permissions: true,93 options: [94 'email'95 ],96 query(frame) {97 return Promise.resolve()98 .then(() => {99 return auth.setup.assertSetupCompleted(true)();100 })101 .then(() => {102 return auth.passwordreset.generateToken(frame.data.passwordreset[0].email, api.settings);103 })104 .then((token) => {105 return auth.passwordreset.sendResetNotification(token, api.mail);106 });107 }108 },109 resetPassword: {110 validation: {111 docName: 'passwordreset',112 data: {113 newPassword: {required: true},114 ne2Password: {required: true}115 }116 },117 permissions: false,118 options: [119 'ip'120 ],121 query(frame) {122 return Promise.resolve()123 .then(() => {124 return auth.setup.assertSetupCompleted(true)();125 })126 .then(() => {127 return auth.passwordreset.extractTokenParts(frame);128 })129 .then((params) => {130 return auth.passwordreset.protectBruteForce(params);131 })132 .then(({options, tokenParts}) => {133 options = Object.assign(options, {context: {internal: true}});134 return auth.passwordreset.doReset(options, tokenParts, api.settings)135 .then((params) => {136 web.shared.middlewares.api.spamPrevention.userLogin().reset(frame.options.ip, `${tokenParts.email}login`);137 return params;138 });139 });140 }141 },142 acceptInvitation: {143 validation: {144 docName: 'invitations'145 },146 permissions: false,147 query(frame) {148 return Promise.resolve()149 .then(() => {150 return auth.setup.assertSetupCompleted(true)();151 })152 .then(() => {153 return invitations.accept(frame.data);154 });155 }156 },157 isInvitation: {158 data: [159 'email'160 ],161 validation: {162 docName: 'invitations'163 },164 permissions: false,165 query(frame) {166 return Promise.resolve()167 .then(() => {168 return auth.setup.assertSetupCompleted(true)();169 })170 .then(() => {171 const email = frame.data.email;172 return models.Invite.findOne({email: email, status: 'sent'}, frame.options);173 });174 }175 }...

Full Screen

Full Screen

db.js

Source:db.js Github

copy

Full Screen

1const mysql = require('promise-mysql')2const roadmap = require('./roadmap');3var con4async function connect() {5 con = await mysql.createConnection(roadmap.dbOptions).catch(e => {6 console.error(e)7 debugger8 })9 console.log('db connected')10}11exports.connect = connect12async function dropTables(minRsiLength,maxRsiLength) {13 for (var rsiLength = minRsiLength; rsiLength <= maxRsiLength; rsiLength++) {14 let sql = `DROP TABLE TradeRsi` + rsiLength15 let results = await con.query(sql).catch(e => console.error(e))16 console.log('done', sql)17 }18}19async function createTables(minRsiLength,maxRsiLength) {20 for (var rsiLength = minRsiLength; rsiLength <= maxRsiLength; rsiLength++) {21 let sql = `CREATE TABLE IF NOT EXISTS TradeRsi` + rsiLength + 22 `(23 SetupRsiOverbought tinyint,24 SetupRsiOversold tinyint,25 SetupStopLossLookBack tinyint,26 SetupProfitFactor smallint,27 EnterTime int,28 EnterType varchar(1),29 EnterCapital int,30 EnterPrice decimal(9,2),31 StopLoss decimal(9,2),32 TakeProfit decimal(9,2),33 ExitTime int,34 ExitPrice decimal(9,2),35 ExitCapital int36 )`37 let results = await con.query(sql).catch(e => console.error(e))38 console.log('done',sql)39 }40}41function startTradeSetup(setup) {42 return43 return {sql:`INSERT INTO TradeRsi` + setup.rsiLength + 44 `(SetupRsiOverbought,SetupRsiOversold,SetupStopLossLookBack,SetupProfitFactor,45 EnterTime,EnterType,EnterCapital,EnterPrice,StopLoss,TakeProfit,46 ExitTime,ExitPrice,ExitCapital) VALUE`,47 params:[],enterCount:0,exitCount:0}48}49var pendingEndTradeSetup50async function endTradeSetup(query) {51 return52 var sql = query.sql, params = query.params53 sql = sql.slice(0, -1)54 if (params.length % 16 !== 0) {55 params = params.concat([null,null,null,null])56 }57 try {58 if (pendingEndTradeSetup) {59 await pendingEndTradeSetup60 }61 else {62 console.log('no pending')63 }64 pendingEndTradeSetup = con.query(sql,params)65 .catch (e => {66 console.log(sql,params)67 console.error(e)68 debugger69 })70 pendingEndTradeSetup.then(result => {71 pendingEndTradeSetup = null72 })73 }74 catch (e) {75 console.log(e)76 debugger77 }78 return79}80function enterTrade(query,rsiOverbought,rsiOversold,stopLossLookBack,profitFactor,type,capital,time,size,price,stopLoss,takeProfit) {81 return82 // query.enterCount++83 query.sql += ` (?,?,?,?,?,?,?,?,?,?,?,?,?),`84 query.params.push(rsiOverbought,rsiOversold,stopLossLookBack,profitFactor,85 time/1000,type,capital,price,stopLoss,takeProfit)86 return87}88function exitTrade(query,time,price,capital) {89 return90 // query.exitCount++91 query.params.push(time/1000,price,capital)92 return93}94async function getTrades(rsiLength, rsiOverbought, rsiOversold, stopLossLookBack, profitFactor) {95 var sql = `select id,type,enter_capital,enter_time,enter_size,enter_price,stop_loss,take_profit,exit_time,exit_price,exit_profit,exit_capital96 from trade where setup_rsilength = ? and setup_rsioverbought = ? and setup_rsioversold = ? and setup_stoplosslookback = ? and setup_profitfactor = ?`97 var result = await con.query(sql,[rsiLength, rsiOverbought, rsiOversold, stopLossLookBack, profitFactor])98 return result99}100exports.dropTables = dropTables101exports.createTables = createTables102exports.startTradeSetup = startTradeSetup103exports.endTradeSetup = endTradeSetup104exports.enterTrade = enterTrade105exports.exitTrade = exitTrade106exports.getTrades = getTrades107// function createDatabase() {108// var con = mysql.createConnection({109// host: "localhost",110// user: "root",111// password: "password"112// });113 114// con.connect(function(err) {115// if (err) throw err;116// console.log("Connected!");117// con.query("CREATE DATABASE survey", function (err, result) {118// if (err) throw err;119// console.log("Database created");120// });121// });122// }...

Full Screen

Full Screen

accounts.js

Source:accounts.js Github

copy

Full Screen

1'use strict';2var helpers = require('./helpers');3var setupPageRoute = helpers.setupPageRoute;4module.exports = function (app, middleware, controllers) {5 var middlewares = [middleware.checkGlobalPrivacySettings, middleware.exposeUid];6 var accountMiddlewares = [middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, middleware.exposeUid];7 setupPageRoute(app, '/me/*', middleware, [], middleware.redirectMeToUserslug);8 setupPageRoute(app, '/uid/:uid*', middleware, [], middleware.redirectUidToUserslug);9 setupPageRoute(app, '/user/:userslug', middleware, middlewares, controllers.accounts.profile.get);10 setupPageRoute(app, '/user/:userslug/following', middleware, middlewares, controllers.accounts.follow.getFollowing);11 setupPageRoute(app, '/user/:userslug/followers', middleware, middlewares, controllers.accounts.follow.getFollowers);12 setupPageRoute(app, '/user/:userslug/posts', middleware, middlewares, controllers.accounts.posts.getPosts);13 setupPageRoute(app, '/user/:userslug/topics', middleware, middlewares, controllers.accounts.posts.getTopics);14 setupPageRoute(app, '/user/:userslug/best', middleware, middlewares, controllers.accounts.posts.getBestPosts);15 setupPageRoute(app, '/user/:userslug/groups', middleware, middlewares, controllers.accounts.groups.get);16 setupPageRoute(app, '/user/:userslug/bookmarks', middleware, accountMiddlewares, controllers.accounts.posts.getBookmarks);17 setupPageRoute(app, '/user/:userslug/watched', middleware, accountMiddlewares, controllers.accounts.posts.getWatchedTopics);18 setupPageRoute(app, '/user/:userslug/ignored', middleware, accountMiddlewares, controllers.accounts.posts.getIgnoredTopics);19 setupPageRoute(app, '/user/:userslug/upvoted', middleware, accountMiddlewares, controllers.accounts.posts.getUpVotedPosts);20 setupPageRoute(app, '/user/:userslug/downvoted', middleware, accountMiddlewares, controllers.accounts.posts.getDownVotedPosts);21 setupPageRoute(app, '/user/:userslug/edit', middleware, accountMiddlewares, controllers.accounts.edit.get);22 setupPageRoute(app, '/user/:userslug/edit/username', middleware, accountMiddlewares, controllers.accounts.edit.username);23 setupPageRoute(app, '/user/:userslug/edit/email', middleware, accountMiddlewares, controllers.accounts.edit.email);24 setupPageRoute(app, '/user/:userslug/edit/password', middleware, accountMiddlewares, controllers.accounts.edit.password);25 setupPageRoute(app, '/user/:userslug/info', middleware, accountMiddlewares, controllers.accounts.info.get);26 setupPageRoute(app, '/user/:userslug/settings', middleware, accountMiddlewares, controllers.accounts.settings.get);27 setupPageRoute(app, '/user/:userslug/uploads', middleware, accountMiddlewares, controllers.accounts.uploads.get);28 setupPageRoute(app, '/user/:userslug/consent', middleware, accountMiddlewares, controllers.accounts.consent.get);29 setupPageRoute(app, '/user/:userslug/blocks', middleware, accountMiddlewares, controllers.accounts.blocks.getBlocks);30 app.delete('/api/user/:userslug/session/:uuid', [middleware.exposeUid, middleware.ensureSelfOrGlobalPrivilege], controllers.accounts.session.revoke);31 setupPageRoute(app, '/notifications', middleware, [middleware.authenticate], controllers.accounts.notifications.get);32 setupPageRoute(app, '/user/:userslug/chats/:roomid?', middleware, middlewares, controllers.accounts.chats.get);33 setupPageRoute(app, '/chats/:roomid?', middleware, [middleware.authenticate], controllers.accounts.chats.redirectToChat);...

Full Screen

Full Screen

scripts.js

Source:scripts.js Github

copy

Full Screen

1function viewCandidates() {2 $('#candidatesContainer').fadeIn();3 $('#btn-viewCandidates').hide();4 $('.welcome-banner h1').addClass('h1-normal');5 $('.welcome-banner p').addClass('p-normal');6 $('.welcome-banner').addClass('welcome-normal');7 $('.bg-banner').removeClass('bg-banner-small');8 $('#resultsContainer').fadeOut();9}10function viewResults() {11 $('#resultsContainer').fadeIn();12 $('#btn-viewResults').hide();13 $('.welcome-banner h1').addClass('h1-normal');14 $('.welcome-banner p').addClass('p-normal');15 $('.welcome-banner').addClass('welcome-normal');16 $('.bg-banner').addClass('bg-banner-small');17 $('#candidatesContainer').fadeOut();18}19$(document).ready(function() {20 var navListItems = $('ul.setup-panel li a'),21 allWells = $('.setup-content');22 allWells.hide();23 navListItems.click(function(e)24 {25 e.preventDefault();26 var $target = $($(this).attr('href')),27 $item = $(this).closest('li');28 29 if (!$item.hasClass('disabled')) {30 navListItems.closest('li').removeClass('active');31 $item.addClass('active');32 allWells.hide();33 $target.show();34 }35 });36 37 $('ul.setup-panel li.active a').trigger('click');38 39 // DEMO ONLY //40 $('#activate-step-2').on('click', function(e) {41 $('ul.setup-panel li:eq(1)').removeClass('disabled');42 $('ul.setup-panel li a[href="#step-2"]').trigger('click');43 });44 $('#activate-step-3').on('click', function(e) {45 $('ul.setup-panel li:eq(2)').removeClass('disabled');46 $('ul.setup-panel li a[href="#step-3"]').trigger('click');47 }); 48 $('#activate-step-4').on('click', function(e) {49 $('ul.setup-panel li:eq(3)').removeClass('disabled');50 $('ul.setup-panel li a[href="#step-4"]').trigger('click');51 52 }); 53 $('#activate-step-5').on('click', function(e) {54 $('ul.setup-panel li:eq(4)').removeClass('disabled');55 $('ul.setup-panel li a[href="#step-5"]').trigger('click');56 }); 57 $('.activate-step-6').on('click', function(e) {58 $('ul.setup-panel li:eq(5)').removeClass('disabled');59 $('ul.setup-panel li a[href="#step-6"]').trigger('click');60 $('ul.setup-panel li:eq(0),ul.setup-panel li:eq(1),ul.setup-panel li:eq(2),ul.setup-panel li:eq(3),ul.setup-panel li:eq(4),ul.setup-panel li:eq(5)').addClass('disabled');61 }); 62 /*63 $('#activate-step-7').on('click', function(e) {64 $('ul.setup-panel li:eq(6)').removeClass('disabled');65 $('ul.setup-panel li a[href="#step-7"]').trigger('click');66 });67 $('#activate-step-8').on('click', function(e) {68 $('ul.setup-panel li:eq(7)').removeClass('disabled');69 $('ul.setup-panel li a[href="#step-8"]').trigger('click');70 }); 71 $('#activate-step-9').on('click', function(e) {72 $('ul.setup-panel li:eq(5)').removeClass('disabled');73 $('ul.setup-panel li a[href="#step-6"]').trigger('click');74 $('ul.setup-panel li:eq(0),ul.setup-panel li:eq(1),ul.setup-panel li:eq(2),ul.setup-panel li:eq(3),ul.setup-panel li:eq(4),ul.setup-panel li:eq(5)').addClass('disabled');75 }); */...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { setup } = require("fast-check-monorepo");2setup();3const { setup } = require("fast-check-monorepo");4setup();5const { setup } = require("fast-check-monorepo");6setup();7const { setup } = require("fast-check-monorepo");8setup();9const { setup } = require("fast-check-monorepo");10setup();11const { setup } = require("fast-check-monorepo");12setup();13const { setup } = require("fast-check-monorepo");14setup();15const { setup } = require("fast-check-monorepo");16setup();17const { setup } = require("fast-check-monorepo");18setup();19const { setup } = require("fast-check-monorepo");20setup();21const { setup } = require("fast-check-monorepo");22setup();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { setup } from 'fast-check-monorepo';2setup();3import * as fc from 'fast-check';4import { setup } from 'fast-check-monorepo';5setup();6import * as fc from 'fast-check';7import { setup } from 'fast-check-monorepo';8setup();9import * as fc from 'fast-check';10import { setup } from 'fast-check-monorepo';11setup();12import * as fc from 'fast-check';13import { setup } from 'fast-check-monorepo';14setup();15import * as fc from 'fast-check';16import { setup } from 'fast-check-monorepo';17setup();18import * as fc from 'fast-check';19import { setup } from 'fast-check-monorepo';20setup();21import * as fc from 'fast-check';22import { setup } from 'fast-check-monorepo';23setup();24import * as fc from 'fast-check';25import { setup } from 'fast-check-monorepo';26setup();27import * as fc from 'fast-check';28import { setup } from 'fast-check-monorepo';29setup();30import * as fc from 'fast-check';

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2fc.configureGlobal({3 beforeEach: () => {4 console.log("beforeEach");5 },6 afterEach: () => {7 console.log("afterEach");8 },9});10fc.assert(11 fc.property(fc.integer(), (n) => {12 console.log("property");13 return n > 0;14 })15);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2fc.assert(3 fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a),4 { numRuns: 1000 }5);6const fc = require('fast-check');7fc.assert(8 fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a),9 { numRuns: 1000 }10);11 at Object.<anonymous> (/home/abhishek/Documents/Work/Projects/fast-check-monorepo/test1.js:3:3)12 at Module._compile (internal/modules/cjs/loader.js:1063:30)13 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)14 at Module.load (internal/modules/cjs/loader.js:928:32)15 at Function.Module._load (internal/modules/cjs/loader.js:769:14)16 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { setup } = require('fast-check-monorepo');2setup();3const fc = require('fast-check');4fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));5const fc = require('fast-check');6fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));7const { setup } = require('fast-check');8setup();9const fc = require('fast-check');10fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));11const fc = require('fast-check-monorepo');12fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));13const { setup } = require('fast-check');14setup();15const fc = require('fast-check');16fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));17const fc = require('fast-check-monorepo');18fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));19const { setup } = require('fast-check-monorepo');20setup();21const fc = require('fast-check');22fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));23const fc = require('fast-check');24fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));25const { setup } = require('fast-check');26setup();27const fc = require('fast-check');28fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { setup } = require("@dubzzz/fast-check");2setup();3const fc = require("fast-check");4function test() {5 fc.assert(6 fc.property(fc.integer(1, 100), fc.integer(1, 100), (a, b) => {7 return a + b > a;8 })9 );10}11test();12const fc = require("fast-check");13const { setup } = require("@dubzzz/fast-check-monorepo");14setup();15function test() {16 fc.assert(17 fc.property(fc.integer(1, 100), fc.integer(1, 100), (a, b) => {18 return a + b > a;19 })20 );21}22test();23const fc = require("fast-check");24const { setup } = require("@dubzzz/fast-check-monorepo");25setup();26function test() {27 fc.assert(28 fc.property(fc.integer(1, 100), fc.integer(1, 100), (a, b) => {29 return a + b > a;30 })31 );32}33test();34const fc = require("fast-check");35const { setup } = require("@dubzzz/fast-check-monorepo");36setup();37function test() {38 fc.assert(39 fc.property(fc.integer(1, 100), fc.integer(1, 100), (a, b) => {40 return a + b > a;41 })42 );43}44test();45const { setup } = require("@dubzzz/fast-check-monorepo");46setup();47const fc = require("fast-check");48function test() {49 fc.assert(50 fc.property(fc.integer(1, 100), fc.integer(1, 100), (a,

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { setup } = require("fast-check-monorepo");3setup();4fc.assert(5 fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a)6);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { setup } = require('fast-check-monorepo');3const { generateArrayOf100NumbersFrom1To10 } = require('./src/arrayOf100NumbersFrom1To10');4describe('testArrayOf100NumbersFrom1To10', () => {5 test('testArrayOf100NumbersFrom1To10', () => {6 const { instance: fastCheckInstance } = setup();7 const arrayOf100NumbersFrom1To10 = fastCheckInstance.array(8 fastCheckInstance.nat(10),9 );10 const result = generateArrayOf100NumbersFrom1To10(arrayOf100NumbersFrom1To10);11 expect(result).toHaveLength(100);12 });13});14const generateArrayOf100NumbersFrom1To10 = (arrayOf100NumbersFrom1To10) => {15 return arrayOf100NumbersFrom1To10;16};17module.exports = {18};19const fc = require('fast-check');20const { setup } = require('fast-check-monorepo');21const { generateArrayOf100NumbersFrom1To10 } = require('./src/arrayOf100NumbersFrom1To10');22describe('testArrayOf100NumbersFrom1To10', () => {23 test('testArrayOf100NumbersFrom1To10', () => {24 const { instance: fastCheckInstance } = setup();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful